[fxruby-users] FXTextField.connect(SEL_CHANGED)

Ralph Shnelvar ralphs at dos32.com
Thu Jul 29 13:01:49 EDT 2010


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>


More information about the fxruby-users mailing list