Page 1 of 1
Does injectKeyBlah fire an event?
Posted: Sun Mar 13, 2011 21:43
by Telcontar
Do all the System::injectKeyBlah or injectMouseBlah functions fire an event?
If so, what event? I cannot seem to locate any event to subscribe to for having the Escape key pressed down. It is being injected with:
CEGUI::System::getSingleton().injectKeyDown(CEGUI::Key::Escape);
Re: Does injectKeyBlah fire an event?
Posted: Sun Mar 13, 2011 22:23
by Kulik
Only the window with input focus gets the event. If you want to globally react to Escape key, you have to handle it separately (most likely at the same place where you inject Escape key)
Re: Does injectKeyBlah fire an event?
Posted: Mon Mar 14, 2011 09:45
by CrazyEddie
Version information is required here. In 0.7.x and later, events will propagate up towards the root only stopping if either something handles the event (such as a user subscribed function) or if the event reaches an editbox (the fact that an editbox will stop propagation of all key events in all cases is not 100% correct behaviour and will be addressed.)
CE
Re: Does injectKeyBlah fire an event?
Posted: Tue Mar 15, 2011 04:22
by Telcontar
0.7.5 is the version I'm using.
And in that case... what event would I need to subscribe to? I've searched through the Events for a number of classes, including Window and System, but found nothing that would let me subscribe to a Escape Key Pressed event. Sadly, the prophetic part of my brain wasn't working, because none of my guess worked either...
CEGUI::WindowManager::getSingleton().getWindow("testWindow")->subscribeEvent(<Random Guess Here>, CEGUI::Event::Subscriber(&killer::onPress, this));
What would I fill in for Random Guess Here?
Re: Does injectKeyBlah fire an event?
Posted: Tue Mar 15, 2011 07:42
by CrazyEddie
Based on what you've said, I think in this case
CEGUI::Window::EventKeyDown would suffice - if it doesn't work, I would check for active CEGUI::Editbox or CEGUI::MultiLineEditbox entities.
Failing this, check the list of all events available to all Window based items:
http://cegui.org.uk/docs/current/classC ... 43c8b245a9CE
Re: Does injectKeyBlah fire an event?
Posted: Tue Mar 15, 2011 22:34
by Telcontar
Ah, yes. That led me to the right answer. Thank you!
I had tried EventKeyDown, but of course that works for more than one key. Had to figure out how to cast the EventArgs in order to access the scancode of the key pressed.