Does injectKeyBlah fire an event?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Telcontar
Just popping in
Just popping in
Posts: 9
Joined: Mon Feb 21, 2011 20:52

Does injectKeyBlah fire an event?

Postby Telcontar » Sun Mar 13, 2011 21:43

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);

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Does injectKeyBlah fire an event?

Postby Kulik » Sun Mar 13, 2011 22:23

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)

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Does injectKeyBlah fire an event?

Postby CrazyEddie » Mon Mar 14, 2011 09:45

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

Telcontar
Just popping in
Just popping in
Posts: 9
Joined: Mon Feb 21, 2011 20:52

Re: Does injectKeyBlah fire an event?

Postby Telcontar » Tue Mar 15, 2011 04:22

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?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Does injectKeyBlah fire an event?

Postby CrazyEddie » Tue Mar 15, 2011 07:42

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 ... 43c8b245a9

CE

Telcontar
Just popping in
Just popping in
Posts: 9
Joined: Mon Feb 21, 2011 20:52

Re: Does injectKeyBlah fire an event?

Postby Telcontar » Tue Mar 15, 2011 22:34

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.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 13 guests