How do I read the pressed state of the shift, ctrl etc keys from within
FXRuby? (And is the correct way to read a Ctrl-A to trap an OnKeypress
for A and check if Ctrl is pressed?)
martin
How do I read the pressed state of the shift, ctrl etc keys from within
FXRuby? (And is the correct way to read a Ctrl-A to trap an OnKeypress
for A and check if Ctrl is pressed?)
martin
def onKeypress(sender, sel, event)
p "keysym=#{event.code} state=#{event.state} text=#{event.text}"
if (event.state & CONTROLMASK) != 0
if event.text == 'a'
p "we got a"
end
end
end
elsewhere you must do
widget.connect(SEL_KEYPRESS, method(:onKeypress))
(untested)
On Fri, 7 Jan 2005 01:26:29 +0900, Martin DeMello <martindemello@yahoo.com> wrote:
How do I read the pressed state of the shift, ctrl etc keys from within
FXRuby? (And is the correct way to read a Ctrl-A to trap an OnKeypress
for A and check if Ctrl is pressed?)
--
Simon Strandgaard
I would change one thing, and that is to check the event.code field
instead of the event.text field, i.e.
if (event.state & CONTROLMASK) != 0
if event.code == KEY_a
...
end
end
... also untested ![]()
-- Lyle
On Fri, 7 Jan 2005 02:28:20 +0900, Simon Strandgaard <neoneye@gmail.com> wrote:
def onKeypress(sender, sel, event)
p "keysym=#{event.code} state=#{event.state} text=#{event.text}"
if (event.state & CONTROLMASK) != 0
if event.text == 'a'
p "we got a"
end
end
end
Thanks to both of you!
martin
Lyle Johnson <lyle.johnson@gmail.com> wrote:
On Fri, 7 Jan 2005 02:28:20 +0900, Simon Strandgaard <neoneye@gmail.com> wrote:
> def onKeypress(sender, sel, event)
> p "keysym=#{event.code} state=#{event.state} text=#{event.text}"
> if (event.state & CONTROLMASK) != 0
> if event.text == 'a'
> p "we got a"
> end
> end
> endI would change one thing, and that is to check the event.code field
instead of the event.text field, i.e.