Handling Input

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

crancran
Just popping in
Just popping in
Posts: 5
Joined: Fri Oct 28, 2011 00:54

Handling Input

Postby crancran » Fri Oct 28, 2011 01:55

I initially decided to wait on dealing with any UI elements of my game until I had some basic principles developed. Therefore, my input controller was designed to perform a key binding lookup upon an OIS keyPressed() call and then dispatched via the event system that particular notification. For example, the A key dispatches a E_PLAYER_MOVEMENT_LEFT event and W dispatches a E_PLAYER_MOVE_FORWARD event. This has worked great thus far for basic player controls. Now I am working to layer in the CEGUI framework so that I can provide UI components to my game.

As a simple example, when the game starts, the standard key bindings are loaded that map the C key to an event E_OPEN_CHARACTER_FRAME. This event is wired to my CCharacterPanel::OnOpen() method. This method basically contains a loadWindowLayout() call to my specific layout.

This character panel has a text box where the player can specify an away message while they step AFK. What I need to be able to allow is if the player's cursor is presently in this text box and it has focus; any and all input should be routed to that text box; however, if the player should click anywhere else on the game window outside of that text box, then the field looses focus and any and all input would then be handled by the default key mapping system again rather than CEGUI handling them being injected.

What are some possibilities or proper way to wire up this type of input handling based upon where the game cursor's present focus resides using a combination of OGRE / OIS / CEGUI ??

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

Re: Handling Input

Postby CrazyEddie » Fri Oct 28, 2011 08:42

The planned "right" way is to inject inputs into cegui which will returns true/false from the 'inject*' functions to indicate whether the event was handled / consumed by the CEGUI subsystem in some way. If the event is not handled you would pass it along to some other part of your system for processing. Of course, in practice, there can never be "one true way", as there are too many specific scenarios and opportunities or needs for customising how things are processed (as well as bugs or other idiosyncrasies that present behaviour other than intended or expected).

In theory, the above approach should work for keyboard input. The inject functions will return true if some kind of Editbox is active and false otherwise. The only thing about your use case which may not happen automatically is the 'clicking off of the editbox' part to deactivate the edit box - I forget right now how this behaves as regard to how cegui decides where to send key inputs (and it's likely different depending on which version you're using).

Sorry I could not give detailed specifics, your question requires and deserves a better answer than I have provided, but I do not have the time to give that answer (mostly because it involves researching to make sure the information I would give is correct, and I do not have time to do that right now).

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests