[fxruby-users] Strange behaviour of FXDataTarget connected to FXTextField

XY$ kwicher at gmail.com
Mon Apr 13 19:26:36 EDT 2009


Thanks I see ...
.. but if I connect my SEL_RIGHTBUTTONRELEASE handler to the
FXDataTarget instead it should receive the message from FXText (I
found out that FXTextField does not sends right button messages) ,
shouldn't it?

I rewrote the application and SEL_CHANGED handler works but
SEL_RIGHTBUTTONRELEASE - does not.

Do I not understand something? :)

Regards

K



require "rubygems"
require "fox16"
include Fox
class MyProject < FXMainWindow
  def initialize (app, title)
    super(app,title, :opts=>DECOR_ALL^(DECOR_SHRINKABLE|
DECOR_STRETCHABLE|DECOR_RESIZE)|
LAYOUT_EXPLICIT,:width=>400,:height=>300)
    @female_target = FXDataTarget.new("")
    female_text = FXText.new(self,:target => @female_target, :selector
=> FXDataTarget::ID_VALUE, :opts => TEXTFIELD_NORMAL|
TEXTFIELD_ENTER_ONLY|
LAYOUT_EXPLICIT,:x=>85, :y=>12,:width=>120, :height=>25)

    @female_target.connect(SEL_RIGHTBUTTONRELEASE) do |sender, sel,
event|
      puts "ooo"
        end

    @female_target.connect(SEL_CHANGED) do |sender, sel, data|
      if data.size>0  and @number_target.value.size>0
        @submit_button.enable
      else
        @submit_button.disable
      end
    end

    @number_target = FXDataTarget.new("")
    number_text = FXTextField.new(self, 25,:target =>
@number_target, :selector => FXDataTarget::ID_VALUE, :opts =>
FRAME_NORMAL|TEXTFIELD_ENTER_ONLY|
LAYOUT_EXPLICIT,:x=>85, :y=>47,:width=>90, :height=>25)
    @number_target.connect(SEL_CHANGED) do |sender, sel, data|
      if data.size >0 and @female_target.value.size>0
        @submit_button.enable
      else
        @submit_button.disable
      end
    end

    @submit_button=FXButton.new
(self,"Submit",:x=>85, :y=>180, :width=>300, :height=>24,:opts=>LAYOUT_EXPLICIT|
BUTTON_NORMAL)
    @submit_button.connect(SEL_COMMAND) do
    end
    @submit_button.disable

  end
  def create
    super
    show(PLACEMENT_SCREEN)
  end
end
app = FXApp.new
MyProject.new(app, "test")
app.create
app.run


On Apr 13, 3:10 pm, Lyle Johnson <l... at lylejohnson.name> wrote:
> On Sun, Apr 12, 2009 at 10:49 PM, kwicher <kwic... at gmail.com> wrote:
> > I have a following small program in which I am enabling or disabling a
> > button depending on the presence of text in the text filed. I am using
> > the FXDataTarget connected to the text field. I also want to add
> > possibility to paste the data into text filed upon pressing right
> > mouse button etc. Now, everything works fine until I try to connect
> > the mouse button action to the text field, then the FXDataTarget stops
> > working.
>
> Right. A widget (such as FXTextField) can only have one message target
> at a time. The FXTextField cannot be connected to both the
> FXDataTarget and the SEL_CHANGED handler (or the commented-out
> SEL_RIGHTBUTTONPRESS handler).
> _______________________________________________
> fxruby-users mailing list
> fxruby-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/fxruby-users


More information about the fxruby-users mailing list