I am using foxGUIb for the gui front end (I don''t believe this is where
my issue
is) but i cannot get a couple of things right.
1st
How do I use the keys.rb file within my project?
Currently I am doing a require ''keys'' and then including it.
this then allows me to access constant variables like KEY_Return etc.
2nd
I am using within my event handler this type of code....
@textfield1.connect(Fox::SEL_KEYPRESS){|a,b,event|
if KEY_Return.to_s == <what do i put in here?>
statements
end
}
I''ve tried...
event.state (this gives me 16, 17 for shift, 20 for Ctrl, 24 for Alt, 16
for backspace & tab & delete & insert so it''s not the
best).
a.to_s and this to be compared to the Key_Return.to_s value but this
fails too.
event.to_s
After having a read of lyle''s PDF I found that there is another method
I hadn''t
known about call code using this gives me a match to the KEY_Return constant
that I was looking for!!
So now I have this....
@textfield1.connect(Fox::SEL_KEYPRESS){|a,b,event|
if KEY_Return.to_s == event.code.to_s
statements in here WILL be actioned ONLY when the keyboard enter key IS
pressed!!
end
}
Hope this may help someone down the track.
dave.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/fxruby-users/attachments/20101016/ff838f91/attachment-0001.html>
> De?: fxruby-users-bounces at rubyforge.org [mailto:fxruby-users- > bounces at rubyforge.org] De la part de dave L > Envoy??: samedi 16 octobre 2010 11:23 > ??: fxruby > Objet?: [fxruby-users] key event capturing - help > > I am using foxGUIb for the gui front end (I don''t believe this is where > my issue is) but i cannot get a couple of things right. > > 1st > How do I use the keys.rb file within my project? > Currently I am doing a require ''keys'' and then including it. > > this then allows me to access constant variables like KEY_Return etc. > > 2nd > I am using within my event handler this type of code.... > > @textfield1.connect(Fox::SEL_KEYPRESS){|a,b,event| > > if KEY_Return.to_s == <what do i put in here?> > statements > end > }Hi, You can use event.code, like this: def onKeyPress(sender, sel, data) if data.code == KEY_Tab end> So now I have this.... > > > @textfield1.connect(Fox::SEL_KEYPRESS){|a,b,event| > > if KEY_Return.to_s == event.code.to_s > statements in here WILL be actioned ONLY when the keyboard enter > key IS pressed!! > end > }OK, then in this case you have to use another event: SEL_KEYRELEASE Best regards, ------------------------------------------------------------- Attik System web : http://www.attiksystem.ch Philippe Lang phone: +41 26 422 13 75 rte de la Fonderie 2 gsm : +41 79 351 49 94 1700 Fribourg pgp : http://keyserver.pgp.com -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 474 bytes Desc: not available URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20101018/a71107b3/attachment.bin>
Thank - you Phillipe, After some scratching around and read Lyle''s PDF again I found reference to this and so that has been sorted :). and yes again I''m using the SEL_KEYRELEASE. many thanks for you''re time and assistance. Dave ________________________________ From: Philippe Lang <philippe.lang at attiksystem.ch> To: "fxruby-users at rubyforge.org" <fxruby-users at rubyforge.org> Sent: Mon, 18 October, 2010 8:12:33 PM Subject: Re: [fxruby-users] key event capturing - help> De : fxruby-users-bounces at rubyforge.org [mailto:fxruby-users- > bounces at rubyforge.org] De la part de dave L > Envoy? : samedi 16 octobre 2010 11:23 > ? : fxruby > Objet : [fxruby-users] key event capturing - help > > I am using foxGUIb for the gui front end (I don''t believe this is where > my issue is) but i cannot get a couple of things right. > > 1st > How do I use the keys.rb file within my project? > Currently I am doing a require ''keys'' and then including it. > > this then allows me to access constant variables like KEY_Return etc. > > 2nd > I am using within my event handler this type of code.... > > @textfield1.connect(Fox::SEL_KEYPRESS){|a,b,event| > > if KEY_Return.to_s == <what do i put in here?> > statements > end > }Hi, You can use event.code, like this: def onKeyPress(sender, sel, data) if data.code == KEY_Tab end> So now I have this.... > > > @textfield1.connect(Fox::SEL_KEYPRESS){|a,b,event| > > if KEY_Return.to_s == event.code.to_s > statements in here WILL be actioned ONLY when the keyboard enter > key IS pressed!! > end > }OK, then in this case you have to use another event: SEL_KEYRELEASE Best regards, ------------------------------------------------------------- Attik System web : http://www.attiksystem.ch Philippe Lang phone: +41 26 422 13 75 rte de la Fonderie 2 gsm : +41 79 351 49 94 1700 Fribourg pgp : http://keyserver.pgp.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20101019/29aa9d04/attachment.html>