I have a simple gui that consists of mostly just a FXText object, and I
would like to react to keys pressed such as q or space. I am fairly new
to Fox, and haven’t been able to glean the answer from any of the Fox or
FXRuby docs online.
···
–
Hans Fugal | De gustibus non disputandum est.
http://hans.fugal.net/ | Debian, vim, mutt, ruby, text, gpg
http://gdmxml.fugal.net/ | WindowMaker, gaim, UTF-8, RISC, JS Bach
GnuPG Fingerprint: 6940 87C5 6610 567F 1E95 CB5E FC98 E8CD E0AA D460
Hans Fugal wrote:
I have a simple gui that consists of mostly just a FXText object, and I
would like to react to keys pressed such as q or space. I am fairly new
to Fox, and haven’t been able to glean the answer from any of the Fox or
FXRuby docs online.
For most widgets, you can intercept the SEL_KEYPRESS and SEL_KEYRELEASE
messages when a key goes down (or up):
aWindow.connect(SEL_KEYPRESS) do |sender, sel, event|
if event.code == KEY_q
puts "q key was pressed"
end
end
aWindow.connect(SEL_KEYRELEASE) do |sender, sel, event|
if event.code == KEY_q
puts "q key was released"
end
end
Hope this helps,
Lyle
Thanks, that did the trick! Now, I can’t figure out how to let the
FXMainWindow capture the event instead of the FXText object (it’s
read-only text; I don’t care about keystrokes in the FXText object in
the least).
···
Lyle Johnson lyle@users.sourceforge.net wrote:
For most widgets, you can intercept the SEL_KEYPRESS and SEL_KEYRELEASE
messages when a key goes down (or up):
–
Hans Fugal | De gustibus non disputandum est.
http://hans.fugal.net/ | Debian, vim, mutt, ruby, text, gpg
http://gdmxml.fugal.net/ | WindowMaker, gaim, UTF-8, RISC, JS Bach
GnuPG Fingerprint: 6940 87C5 6610 567F 1E95 CB5E FC98 E8CD E0AA D460