How to call a button action from a key press?

AlexSawczuk

18-08-2011 04:15:34

Hi,

I was wondering what the best way to add 'keyboard' shortcuts to buttons etc is. So that when I press this key it triggers the same delegate as the eventMouseButtonClick does. I see there's a eventKeyButtonPressed action, can I use this to do that? Or does that only work went the item has 'focus', I kinda want to press escape for exit, space for resume etc.


Cheers

Altren

18-08-2011 07:21:20

eventKeyButtonPressed as well as most other events works only with focused widget.
What you need to do is not really part of gui, since it is not tied to any widget. You should add such code in same place where you call MyGUI::InputManager::getInstance().injectKeyPress(...)