kwicher
2009-Apr-13 03:49 UTC
[fxruby-users] Strange behaviour of FXDataTarget connected to FXTextField
Hi 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. I am attaching the program; the mouse staff is commented out. Please have a look test the program with un- and commented lines. #---------- 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 = FXTextField.new(self, 25,:target => @female_target, :selector => FXDataTarget::ID_VALUE, :opts => TEXTFIELD_NORMAL|TEXTFIELD_ENTER_ONLY| LAYOUT_EXPLICIT,:x=>85, :y=>12,:width=>120, :height=>25) #female_text.connect(SEL_RIGHTBUTTONRELEASE) do |sender, sel, event| # 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 #--------- Thanks Krzys
Lyle Johnson
2009-Apr-13 14:10 UTC
[fxruby-users] Strange behaviour of FXDataTarget connected to FXTextField
On Sun, Apr 12, 2009 at 10:49 PM, kwicher <kwicher 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).
XY$
2009-Apr-13 23:26 UTC
[fxruby-users] Strange behaviour of FXDataTarget connected to FXTextField
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
Lyle Johnson
2009-Apr-14 13:04 UTC
[fxruby-users] Strange behaviour of FXDataTarget connected to FXTextField
On Apr 13, 2009, at 6:26 PM, XY$ wrote:> 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''m pretty sure that FXDataTarget only forwards SEL_COMMAND and SEL_CHANGED messages to its target, so no, you wouldn''t get the SEL_RIGHTBUTTONRELEASE message.
XY$
2009-Apr-14 16:24 UTC
[fxruby-users] Strange behaviour of FXDataTarget connected to FXTextField
If it is like that, what should be the target for the FXText so that I can handle SEL_RIGHTBUTTONRELEASE message sent by it? Should the target be self? Thanks K On Apr 14, 2:04?pm, Lyle Johnson <l... at lylejohnson.name> wrote:> On Apr 13, 2009, at 6:26 PM, XY$ wrote: > > > 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''m pretty sure that FXDataTarget only forwards SEL_COMMAND and ? > SEL_CHANGED messages to its target, so no, you wouldn''t get the ? > SEL_RIGHTBUTTONRELEASE message. > _______________________________________________ > fxruby-users mailing list > fxruby-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/fxruby-users
Lyle Johnson
2009-Apr-14 17:48 UTC
[fxruby-users] Strange behaviour of FXDataTarget connected to FXTextField
On Tue, Apr 14, 2009 at 11:24 AM, XY$ <kwicher at gmail.com> wrote:> If it is like that, what should be the target for the FXText so that I > can handle SEL_RIGHTBUTTONRELEASE message sent by it? Should the > target be self?Well, there''s nothing special about it, but I''d probably just use an anonymous handler, e.g. text_widget.connect(SEL_RIGHTBUTTONRELEASE) do # handle right button release on text widget end Hope this helps, Lyle
XY$
2009-Apr-14 22:24 UTC
[fxruby-users] Strange behaviour of FXDataTarget connected to FXTextField
Thanks a lot. I got it and it works. K On 14 Apr, 18:48, Lyle Johnson <l... at lylejohnson.name> wrote:> On Tue, Apr 14, 2009 at 11:24 AM, XY$ <kwic... at gmail.com> wrote: > > If it is like that, what should be the target for the FXText so that I > > can handle SEL_RIGHTBUTTONRELEASE message sent by it? Should the > > target be self? > > Well, there''s nothing special about it, but I''d probably just use an > anonymous handler, e.g. > > ? ? text_widget.connect(SEL_RIGHTBUTTONRELEASE) do > ? ? ? # handle right button release on text widget > ? ? end > > Hope this helps, > > Lyle > _______________________________________________ > fxruby-users mailing list > fxruby-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/fxruby-users