Philippe Lang
2007-Jan-25 07:50 UTC
[fxruby-users] SEL_CHANGED event for FXText and FXTextfield
Hi,
I have noticed a small difference between the SEL_CHANGED event of an
FXText and an FXTextfield: in an FXText, the SEL_CHANGED event gets
fired even if the content does not "change", like when the selection
changes. You can test that with the following test program.
I imagine this is no bug at all. But from a "symetry" point of view
:),
I was expecting both events to mean the same in two similar widgets. The
equivalent event for an FXText is actually SEL_REPLACED. It took me some
time to figure it out!
Anyway, this is not a big deal at all.
Regards,
Philippe
-----------------------------------------
require ''fox16''
include Fox
class MyWindow < FXMainWindow
def initialize(app)
super(app, "Window", nil, nil, DECOR_ALL, 0, 0, 200, 100)
text_field = FXTextField.new(self, 15)
text_field.text = "1234567890abcd"
text_field.connect(SEL_CHANGED, method(:onTextFieldChange))
text_area = FXText.new(self, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y)
text_area.text = "1234567890abcd"
text_area.connect(SEL_CHANGED, method(:onTextAreaChange))
end
def onTextFieldChange(sender, selector, data)
puts "onTextFieldChange"
end
def onTextAreaChange(sender, selector, data)
puts "onTextAreaChange"
end
def create
super
show(PLACEMENT_SCREEN)
end
end
if __FILE__ == $0
application = FXApp.new("Fox", "FXRuby Test")
MyWindow.new(application)
application.create
application.run
end
Jeroen van der Zijp
2007-Jan-25 13:10 UTC
[fxruby-users] SEL_CHANGED event for FXText and FXTextfield
On Thursday 25 January 2007 01:50, Philippe Lang wrote:> Hi, > > I have noticed a small difference between the SEL_CHANGED event of an > FXText and an FXTextfield: in an FXText, the SEL_CHANGED event gets > fired even if the content does not "change", like when the selection > changes. You can test that with the following test program. > > I imagine this is no bug at all. But from a "symetry" point of view :), > I was expecting both events to mean the same in two similar widgets. The > equivalent event for an FXText is actually SEL_REPLACED. It took me some > time to figure it out!I''m actually thinking of FXTextField as a kind of valuator [like FXSlider and FXDial], and FXText as something else. Its often a judgement call as you can also come up with arguments why FXTextField should be like FXText. Regards, - Jeroen -- +----------------------------------------------------------------------------+ | Copyright (C) 07:00 01/25/2007 Jeroen van der Zijp. All Rights Reserved. | +----------------------------------------------------------------------------+
Philippe Lang
2007-Jan-25 13:20 UTC
[fxruby-users] SEL_CHANGED event for FXText and FXTextfield
Jeroen van der Zijp wrote:> On Thursday 25 January 2007 01:50, Philippe Lang wrote: >> Hi, >> >> I have noticed a small difference between the SEL_CHANGED event of an >> FXText and an FXTextfield: in an FXText, the SEL_CHANGED event gets >> fired even if the content does not "change", like when the selection >> changes. You can test that with the following test program. >> >> I imagine this is no bug at all. But from a "symetry" point of view >> :), I was expecting both events to mean the same in two similar >> widgets. The equivalent event for an FXText is actually SEL_REPLACED. >> It took me some time to figure it out! > > I''m actually thinking of FXTextField as a kind of valuator [like > FXSlider and FXDial], and FXText as something else. > > Its often a judgement call as you can also come up with arguments why > FXTextField should be like FXText.OK I understand now, this is clear. Anyway, this is really a detail, FXRuby works just fine, and let me thanks you again for that! Cheers, Philippe