Filter CEGUI::PushButton::EventKeyDown

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

RecyclingDuck
Just popping in
Just popping in
Posts: 13
Joined: Tue May 15, 2007 20:17
Contact:

Filter CEGUI::PushButton::EventKeyDown

Postby RecyclingDuck » Thu Jun 07, 2007 14:17

Hey,

it's me again :P

I've got another question:

My aim is to code something like a commandline.
So I need to react to the case, that the user (of the application) presses "Enter" - on condition that the editbox is active.

That's what i tried:

Code: Select all

mWindowMgr->getWindow("COMMANDLINE")->subscribeEvent(CEGUI::PushButton::EventKeyDown, CEGUI::Event::Subscriber(&Menu::ConsoleEnter,  this));


But now i've to filter CEGUI::PushButton::EventKeyDown, because I'm only looking for the case, that the enter button has been pressed.

Some ideas !?
- Note: I'm from Germany, please tell me if i make some mistakes - that would help me ;)

Thanks!

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Thu Jun 07, 2007 16:23

CEGUI::PushButton::EventKeyDown

Maybe you meant Editbox.

Have a look at http://www.cegui.org.uk/wiki/index.php/Tab_Order where I react to the tab and shift-tab keys.

RecyclingDuck
Just popping in
Just popping in
Posts: 13
Joined: Tue May 15, 2007 20:17
Contact:

Postby RecyclingDuck » Fri Jun 08, 2007 13:28

Nice :)

The wiki entry contained the correct answer ;)

Here is the solution:

Code: Select all

   bool Menu::ConsoleEnter(const CEGUI::EventArgs& e)
   {
      if(static_cast<const CEGUI::KeyEventArgs&>(e).scancode == 0x1C)
          MessageBoxA(NULL,"","",MB_OK);
      return true;
   }
- Note: I'm from Germany, please tell me if i make some mistakes - that would help me ;)



Thanks!

User avatar
Levia
Quite a regular
Quite a regular
Posts: 83
Joined: Mon May 22, 2006 18:25
Location: Bergen op zoom, The Netherlands
Contact:

Postby Levia » Fri Jun 08, 2007 17:53

you could also simply subscribe to EventTextAccepted, which is fired when enter or tab is pressed.
Image
Image


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests