Mark Dootson wrote:
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 );

Mark thanks! I think this is the example I was looking for.

Reply via email to