When I do an assignment to the text in a FXTextField, SEL_CHANGED is not raised. The text is changed on the screen. How do I detect that the text has been changed and/or ... how do I raise SEL_CHANGED? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20100728/e0d169e5/attachment.html>
On Jul 28, 2010, at 5:35 PM, Ralph Shnelvar <ralphs at dos32.com> wrote:> When I do an assignment to the text in a FXTextField, SEL_CHANGED is not raised. >Try calling setText("new value", true) on the FXTextField instead of assigning to the "text" attribute. That should cause it to notify the text field''s target of the SEL_CHANGED event.
Lyle, Thank you for your attempt, Lyle. As far as I can tell, the setText does, indeed, set the text but does not signal SEL_CHANGED. Where can I find the source to FXRuby? I don''t want to build ... I just want the source because I could not find any documentation that shows that setText takes two parameters. Ralph Wednesday, July 28, 2010, 9:55:39 PM, you wrote: LJ> On Jul 28, 2010, at 5:35 PM, Ralph Shnelvar <ralphs at dos32.com> wrote:>> When I do an assignment to the text in a FXTextField, SEL_CHANGED is not raised.LJ> Try calling setText("new value", true) on the FXTextField instead of assigning to the "text" attribute. That should LJ> cause it to notify the text field''s target of the SEL_CHANGED event. LJ> _______________________________________________ LJ> fxruby-users mailing list LJ> fxruby-users at rubyforge.org LJ> http://rubyforge.org/mailman/listinfo/fxruby-users -- Best regards, Ralph mailto:ralphs at dos32.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20100729/917753b2/attachment-0001.html>
gem server http://127.0.0.1:8808/doc_root/fxruby-1.6.16/rdoc/index.html under FXText::setText setText(text, notify=false) <http://127.0.0.1:8808/doc_root/fxruby-1.6.16/rdoc/classes/Fox/FXText.src/M002482.html> Change the text If *notify* is true, SEL_INSERTED and SEL_CHANGED messages are sent to the text widget?s message target after the new<http://127.0.0.1:8808/doc_root/fxruby-1.6.16/rdoc/classes/Fox/FXText.html#M002460>text is set. In any case http://www.fxruby.org/doc/api/ seems to have the latest documentation as well. As far as source goes, under linux you can find it under: /usr/lib/ruby/gems/1.8/gems/fxruby-1.6.16/ext/fox16 Where 1.6.16 would be replaced with the version of fxruby you are running. On Thu, Jul 29, 2010 at 10:52 AM, Ralph Shnelvar <ralphs at dos32.com> wrote:> Lyle, > > > Thank you for your attempt, Lyle. > > > As far as I can tell, the setText does, indeed, set the text but does not > signal SEL_CHANGED. > > > Where can I find the source to FXRuby? I don''t want to build ... I just > want the source because I could not find any documentation that shows that > setText takes two parameters. > > > Ralph > > > Wednesday, July 28, 2010, 9:55:39 PM, you wrote: > > > LJ> On Jul 28, 2010, at 5:35 PM, Ralph Shnelvar <ralphs at dos32.com> wrote: > > >> When I do an assignment to the text in a FXTextField, SEL_CHANGED is not > raised. > > > LJ> Try calling setText("new value", true) on the FXTextField instead of > assigning to the "text" attribute. That should > > LJ> cause it to notify the text field''s target of the SEL_CHANGED event. > > LJ> _______________________________________________ > > LJ> fxruby-users mailing list > > LJ> fxruby-users at rubyforge.org <fxruby-users at rubyforge.org> > > LJ> http://rubyforge.org/mailman/listinfo/fxruby-users<http://rubyforge.org/mailman/listinfo/fxruby-users> > > > > > -- > > Best regards, > > Ralph mailto:ralphs at dos32.com<ralphs at dos32.com> > > _______________________________________________ > fxruby-users mailing list > fxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/fxruby-users >-- If you are not the intended recipient, you are hereby notified that any dissemination, distribution, copying or other use of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20100729/a2d6c5be/attachment.html>
On Thu, Jul 29, 2010 at 9:52 AM, Ralph Shnelvar <ralphs at dos32.com> wrote:> As far as I can tell, the setText does, indeed, set the text but does not > signal SEL_CHANGED.Ah, you''re right. It actually sends SEL_COMMAND for that case. I was thinking of the multiline FXText widget, which *does* send SEL_CHANGED in that circumstance. I don''t know why Jeroen (FOX''s author) made those two inconsistent. If I read the code correctly, it looks like FXTextField sends SEL_CHANGED as the user makes individual changes to the text (e.g. typing in new characters, deleting text), so that''s the difference.> Where can I find the source to FXRuby? I don''t want to build ... I just want > the source because I could not find any documentation that shows that > setText takes two parameters.The source code repository is here: http://github.com/lylejohnson/fxruby/tree/1.6 and the source (actually, the SWIG interface file from which the source code is generated) for FXTextField is here: http://github.com/lylejohnson/fxruby/blob/1.6/swig-interfaces/FXTextField.i There, you will see that the setText() method is declared as: /// Set the text for this label void setText(const FXString& text,FXbool notify=FALSE); The second argument ("notify") is false by default, which is to say that if you just call: textfield.setText("new text") it won''t send a SEL_COMMAND message to the FXTextField''s target. Now, what you might also want to see (for additional insight) is the FOX source code to which this links. You can download the source code for FOX 1.6 here: http://www.fox-toolkit.org/download.html and if you look at FXTextField.cpp, you''ll find this definition of the function: // Change the text and move cursor to end void FXTextField::setText(const FXString& text,FXbool notify){ killSelection(); if(contents!=text){ contents=text; anchor=contents.length(); cursor=contents.length(); if(xid) layout(); if(notify && target){target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)contents.text());} } } Hope this helps, Lyle
Lyle, Thank you for your in-depth help, Lyle. That was the correct answer. My code now works with the setText. - - - - - So ... continuing ... I have in my code ... @v_file_FXTextField.connect(SEL_CHANGED) do |sender, sel, data| v_model.filename = sender.text.strip end @v_file_FXTextField.connect(SEL_COMMAND) do |sender, sel, data| v_model.filename = sender.text.strip end which seems to work fine. The following does not seem to work worth a damn ... @v_file_FXTextField.connect(SEL_CHANGED|SEL_COMMAND) do |sender, sel, data| v_model.filename = sender.text.strip end Is there a way to do what I want which is to have a single connect do two, uh, connections? Ralph Thursday, July 29, 2010, 9:52:36 AM, you wrote: LJ> On Thu, Jul 29, 2010 at 9:52 AM, Ralph Shnelvar <ralphs at dos32.com> wrote:>> As far as I can tell, the setText does, indeed, set the text but does not >> signal SEL_CHANGED.LJ> Ah, you''re right. It actually sends SEL_COMMAND for that case. I was LJ> thinking of the multiline FXText widget, which *does* send SEL_CHANGED LJ> in that circumstance. I don''t know why Jeroen (FOX''s author) made LJ> those two inconsistent. LJ> If I read the code correctly, it looks like FXTextField sends LJ> SEL_CHANGED as the user makes individual changes to the text (e.g. LJ> typing in new characters, deleting text), so that''s the difference.>> Where can I find the source to FXRuby? I don''t want to build ... I just want >> the source because I could not find any documentation that shows that >> setText takes two parameters.LJ> The source code repository is here: LJ> http://github.com/lylejohnson/fxruby/tree/1.6 LJ> and the source (actually, the SWIG interface file from which the LJ> source code is generated) for FXTextField is here: LJ> http://github.com/lylejohnson/fxruby/blob/1.6/swig-interfaces/FXTextField.i LJ> There, you will see that the setText() method is declared as: LJ> /// Set the text for this label LJ> void setText(const FXString& text,FXbool notify=FALSE); LJ> The second argument ("notify") is false by default, which is to say LJ> that if you just call: LJ> textfield.setText("new text") LJ> it won''t send a SEL_COMMAND message to the FXTextField''s target. Now, LJ> what you might also want to see (for additional insight) is the FOX LJ> source code to which this links. You can download the source code for LJ> FOX 1.6 here: LJ> http://www.fox-toolkit.org/download.html LJ> and if you look at FXTextField.cpp, you''ll find this definition of the function: LJ> // Change the text and move cursor to end LJ> void FXTextField::setText(const FXString& text,FXbool notify){ LJ> killSelection(); LJ> if(contents!=text){ LJ> contents=text; LJ> anchor=contents.length(); LJ> cursor=contents.length(); LJ> if(xid) layout(); LJ> if(notify && target){target->>tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)contents.text());} LJ> } LJ> } LJ> Hope this helps, LJ> Lyle LJ> _______________________________________________ LJ> fxruby-users mailing list LJ> fxruby-users at rubyforge.org LJ> http://rubyforge.org/mailman/listinfo/fxruby-users -- Best regards, Ralph mailto:ralphs at dos32.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20100729/63b006f7/attachment.html>
On Thu, Jul 29, 2010 at 12:01 PM, Ralph Shnelvar <ralphs at dos32.com> wrote:> The following does not seem to work worth a damn ... > > ? ? @v_file_FXTextField.connect(SEL_CHANGED|SEL_COMMAND) do |sender, sel, > data| > ? ? ? v_model.filename = sender.text.strip > ? ? end > > Is there a way to do what I want which is to have a single connect do two, > uh, connections?There''s no way to have a single call to connect() do what you want; each call to connect() wires up exactly one message handler. So you have at least a couple of options here. Because the block''s body (the stuff between "do" and "end") is so short anyways, I''d probably just write out the two statements and call it a day. But if it were something more involved, I''d probably pull it out into a separate method, e.g. def update_model_filename(sender, sel, data) v_model.filename = sender.text.strip # ... possibly a lot more code that we don''t want to duplicate ... end and then call that from the connect() statements'' blocks, i.e. @v_file_FXTextField.connect(SEL_CHANGED) do |sender, sel, data| update_model_filename(sender, sel, data) end @v_file_FXTextField.connect(SEL_CHANGED) do |sender, sel, data| update_model_filename(sender, sel, data) end Along these lines, there''s a two-argument form of connect(), where you pass in some "callable" object as the second argument. So we could more compactly write those two connect() statements as: @v_file_FXTextField.connect(SEL_CHANGED, method(:update_model_filename)) @v_file_FXTextField.connect(SEL_COMMAND, method(:update_model_filename)) Here, the "method()" method (part of the Ruby core) takes a symbol as its input and returns a Method object. Hope this helps, Lyle