[fxruby-users] Working hotkeys example (FXAccelTable)?

Lyle Johnson lyle at knology.net
Sun Apr 24 22:53:49 EDT 2005

On Apr 24, 2005, at 7:04 PM, Jacob Hanson wrote:

> I'm having trouble getting hotkeys to work in FXRuby. For my app, or
> at least a window, can I define a global hotkey for it so that I could
> ,say, press F5 and run some function? I've messed with FXAccelTable
> and looked all over the place, but I still can't get them to work.
> Anyone have a working example?

The datatarget.rb program in the "examples" directory of the FXRuby 
distribution provides one such example. Take a look around line 175:

	# Install an accelerator
	self.accelTable.addAccel(fxparseAccel("Ctl-Q"), getApp(), 

and change the text in the call to fxparseAccel() to some other 
accelerator key, e.g.

	self.accelTable.addAccel(fxparseAccel("F5"), getApp(), 

This says that when the user presses the F5 key, the accelerator table 
will send a message with type SEL_COMMAND and identifier FXApp::ID_QUIT 
to the application object (which is returned by the call to getApp). In 
your case you'll probably want to send some other message to some other 

Hope this helps,


More information about the fxruby-users mailing list