From: Jos Backus Date: 2002-02-09T11:19:29+09:00 Subject: Re: FXRuby: how to create a static status line? On Sat, Feb 09, 2002 at 10:25:39AM +0900, Lyle Johnson wrote: > # Handle SEL_KEYPRESS events instead of SEL_COMMAND or > # SEL_CHANGED > @comment.connect(SEL_KEYPRESS) do | sender, sel, event | > if (event.code == KEY_Return) || (event.code == KEY_KP_Enter) > # User clicked the Enter key; save this event message and then > # return 1 from this handler to let FOX know that we've handled > # the event. > return 1 > else > # It wasn't the Enter key, so we return 0 to let FOX know that > # we didn't handle this event and we want the text field to > handle > # it like it usually would... > return 0 > end > end > > Needless to say, I haven't actually tried this code yet ;) Let me know how > it goes. Adding @comment = FXTextField.new(commentframe, 60, nil, 0, TEXTFIELD_NORMAL|LAYOUT_FILL_X) @comment.connect(SEL_KEYPRESS) { |sender, sel, event| if (event.code == KEY_Return) || (event.code == KEY_KP_Enter) # User clicked the Enter key; save this event message and then # return 1 from this handler to let FOX know that we've handled # the event. unless @comment.text.empty? addevent end return 1 else # It wasn't the Enter key, so we return 0 to let FOX know that # we didn't handle this event and we want the text field to # it like it usually would... return 0 end } gives: lizzy:~% ./fxev.rb /usr/local/lib/ruby/site_ruby/1.6/fox/responder2.rb:29:in `call': return from proc-closure (LocalJumpError) from /usr/local/lib/ruby/site_ruby/1.6/fox/responder2.rb:29:in `onHandleMsg' from ./fxev.rb:260:in `run' from ./fxev.rb:260 > There's not a whole book on FXRuby (or FOX for that matter), but FXRuby is > discussed in at least two new books: "The Ruby Way", by Hal Fulton; and the > "Ruby Developer's Guide", by Michael Neumann (ed.), Robert Feldt, Jonothon > Ortiz and, yes, me. Both of these should be available (or available soon) > from your favorite online or offline bookseller. OK, I'll have a look :) -- Jos Backus _/ _/_/_/ Santa Clara, CA _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ josb@cncdsl.com _/_/ _/_/_/ use Std::Disclaimer;