Hi Mattia, Thanks for that, I had given up on experimentation.
2009/1/19 Mattia Barbon <[email protected]>: >> I'm trying to set entries in AcceleratorTable to something other than >> a button or menuitem - surely there is a way to do this ? > > Not sure what you mean, but while you need to bind accelerators > with EVT_MENU, there is no requirement there is an actual menu item. > >> What I want to do is add some hotkeys to specific internal functions >> to implement some emacs-like keybindings, I could make this work with >> keydown event handling, >> but that's a bit slow, tedious and hacky. > > $self->SetAcceleratorTable > ( Wx::AcceleratorTable->new > ( [ wxACCEL_ALT, 'P', $ID_ACCEL_SEARCH ], > ... > ) ); > > EVT_MENU( $self, $ID_ACCEL_SEARCH, > sub { $self->_controls->set_focus_text } ); > > > And I have no menu item (and the button I use for search > has a separate ID and event binding). So the ID just has to be a unique number, not necessarily tied to a widget. Ideally I'd like to be able to have multiple entries in the AcceleratorTable call the same sub which then checked which keys were pressed, but unfortunately EVT_MENU won't have GetModifier/GetKey will it ? Presumably I can just generate a list of unique IDs, and get the ID from the event somehow in the handler sub ? A. A. -- http://www.aarontrevena.co.uk LAMP System Integration, Development and Hosting
