Page 1 of 1
Some questions, CEGUI 0.2.0
Posted: Mon Mar 14, 2005 17:54
by Nocs
1st question)
How can i register a EventKeyDown to a Editbox?
i have tried with
Code: Select all
bool handleSendButtonKey(const CEGUI::KeyEventArgs& e)
{
.....
}
....
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
wmgr.getWindow("client_lobby\\chat\\editbox")
->subscribeEvent(
CEGUI::Window::EventKeyDown,
CEGUI::Event::Subscriber(&handleSendButtonKey));
but it gives me a compiling error.
2nd question)
How can i redirect all the inputs to a FrameWindow so that all the other widgets cant become inputs for the time the FrameWindow is active (like ShowModal() in delphi)??
Thanks
Re: Some questions, CEGUI 0.2.0
Posted: Mon Mar 14, 2005 21:37
by rincewind
for your second question, this is the code I use to make a framewindow modal:
Code: Select all
bool keepActivated(const CEGUI::EventArgs & e)
{
((CEGUI::WindowEventArgs*)&e)->window->activate();
return true;
}
//on initialization:
myFramewindow->subscribeEvent(
CEGUI::Window::EventDeactivated,
CEGUI::Event::Subscriber(&keepActivated));
Beware though that if you do that with two windows at the same time, you end up gettting stuck in an infinite loop. So always guard the connection object for the subscription and unsubscribe from it. You might want to encapsulate this somehow, so it's more or lesss guaranteed that only one window is modal at a time.
Greetings,
Rincewind
Re: Some questions, CEGUI 0.2.0
Posted: Tue Mar 15, 2005 09:23
by CrazyEddie
The signature for the event handler is incorrect. It takes a const EventArgs&, once in the function you can cast to whatever the 'real' type is.
HTH
CE.
Re: Some questions, CEGUI 0.2.0
Posted: Tue Mar 15, 2005 17:22
by Nocs
Thanks for te reply CE.
Is there a flexibler way (for example function call of FrameWindow) to show a FrameWindow Modal than the suggestion of rincewind?
Re: Some questions, CEGUI 0.2.0
Posted: Tue Mar 15, 2005 19:36
by CrazyEddie
There's nothing currently built-in to provide this functionality. I will likely add a set of 'higher level' utility classes which will achieve this kind of thing, though unfortunately this kind of thing is not on the radar at the moment.
So for the time being you need to implement this yourself, the suggestion made by rincewind is certainly valid. You might be able to do something via the captureInputs call, though there are various pitfalls here too, so you'd need to monitor when you 'lose' the catpure and re-aquire it. You'd also need to ensure that inputs were forwarded from the root capture window to child windows. These suggestions are still not the 'only' ways of doing this, I do understand that all of these solutions seem a bit 'hackish'.
CE.