[fxruby-users] key event capturing - help

Philippe Lang philippe.lang at attiksystem.ch
Mon Oct 18 03:12:33 EDT 2010


> 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>


More information about the fxruby-users mailing list