Hi,

The in-built 'hot key' processing in wxPerl associates hot-keys with 'commands' 
(for example, menu items or buttons)

So, if you had a menu command "File->Exit", you might specify the text label 
for the Exit menuitem as:

"E&xit\tCtrl+X"

This would give you the usual Alt, F, X route to exit, and additionally Ctrl+X 
would cause the command event to trigger. From my reading of the docs, you 
can't specify 'Esc' alone in this way (it would have to be Ctrl+ESC or similar 
with Alt or shift).

So, to do what you want, you need an accelerator table.

See docs for wxAcceleratorEntry and wxAcceleratorTable.

You want to add keycode WXK_ESCAPE as accelerator entry for Exit menuitemid.

I can't put my hands on any working example code, but I'm pretty sure following 
none tested code would work.


my $table = Wx::AcceleratorTable->new( [wxACCEL_NORMAL, WXK_ESCAPE, 
$exitmenuitemid] );
$frame->SetAcceleratorTable( $table );


Regards

Mark



James McDonald wrote:

I would like to close my application by pressing the escape key.

I know I have to define the escape key press event and specify a sub routine that will trigger when I press escape. However I haven't been able to google an example.

Could anyone point me in the right direction?






Reply via email to