How can I use the keyboard to control the menu?

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

reigys
Just popping in
Just popping in
Posts: 2
Joined: Wed Mar 16, 2011 08:08

How can I use the keyboard to control the menu?

Postby reigys » Wed Mar 16, 2011 08:35

Hi there,
I am a newbie to CEGUI, and English is not my mother language. Sorry for I my poor English.
I want to use keyboard to control a menu in games. That means, navigate the menu with UP ARROW key and DOWN ARROW key, and confirm with ENTER key. I find this post: http://www.cegui.org.uk/phpBB2/viewtopic.php?t=3321 . But when I add "mGUIManager->injectKeyDown(arg)" to my code, I find this function returns false, and CEGUI cannot handle the key input. I don't why. The code goes as follow:

Code: Select all

bool GameApp::keyPressed( const OIS::KeyEvent &arg )
   {
      if(mGUIManager->injectKeyDown(arg))
         Ogre::LogManager::getSingleton().logMessage("[GameApp]injectKeyDown to CEGUI OK.");
      
      return mStateManager->keyPressed(arg);
   }


and injectKeyDown(arg) is defined as

Code: Select all

inline bool injectKeyDown(OIS::KeyEvent arg)
      {
         return (mpGUISystem->injectKeyDown(arg.key) && mpGUISystem->injectChar(arg.text));
      }


Strangely, all of injectMouseButtonDown(), injectMouseButtonUp() and injectMouseMove() return true, and I can use the mouse in CEGUI.
Any help will be appreciated.

reigys
Just popping in
Just popping in
Posts: 2
Joined: Wed Mar 16, 2011 08:08

Re: How can I use the keyboard to control the menu?

Postby reigys » Wed Mar 16, 2011 08:43

PS: my menu is a layout which consists of a framewindow and four buttons in Vanilla skin. But I think it has nothing to do with my problem. :?

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

Re: How can I use the keyboard to control the menu?

Postby Kulik » Wed Mar 16, 2011 09:45

AFAIK CEGUI doesn't support this out of the box in 0.7 but this is planned for 0.8. You can do this yourself by listening to key up down events in the frame window and activating child buttons accordingly. When the button has focus, you would listen to Enter/Space key event.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: How can I use the keyboard to control the menu?

Postby Jamarr » Wed Mar 16, 2011 20:49

reigys, there is an article on the wiki that may help: Tab Order. Note I have never used this, and if it works may need to be modified to work with v0.7. Make sure you search the wiki and forums before asking help; this helps avoid clutter on the forums. And please post in the appropriate sub-forum next time (this should be in Beginners Help) as this helps maintain an organized forum. Thanks ;)

Kulik wrote:AFAIK CEGUI doesn't support this out of the box in 0.7 but this is planned for 0.8.


So you are planning on adding a keyboard-focus state in v0.8? If so, what keys will this support by default (tab/shift-tab, arrows, enter/space, home/end, page up/down, esc)? Just curious :)
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

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

Re: How can I use the keyboard to control the menu?

Postby Kulik » Wed Mar 16, 2011 22:27

Jamarr wrote:So you are planning on adding a keyboard-focus state in v0.8? If so, what keys will this support by default (tab/shift-tab, arrows, enter/space, home/end, page up/down, esc)? Just curious :)


CrazyEddie plans to do that. I imagine it will be configurable.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 4 guests