Page 1 of 1

Filter CEGUI::PushButton::EventKeyDown

Posted: Thu Jun 07, 2007 14:17
by RecyclingDuck
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 !?

Posted: Thu Jun 07, 2007 16:23
by Rackle
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.

Posted: Fri Jun 08, 2007 13:28
by RecyclingDuck
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;
   }

Posted: Fri Jun 08, 2007 17:53
by Levia
you could also simply subscribe to EventTextAccepted, which is fired when enter or tab is pressed.