Keyboard Events on Modal Window

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

Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Sep 22, 2009 02:26

Keyboard Events on Modal Window

Postby rockoz » Sat Aug 07, 2010 02:48

I'm using Modal Window these days and I find it is hard to meet my needs.

Generally I expect the child window of modal window can propogate the keyboard events( key down, up and char) to the modal window itself.
So I can handle all unhandled keyboard events using the modal window's onKeyXXXX like functions.
But the code in CEGUIWindow.cpp seems to prevent this. And I only can archeive this by subscribe handlers to all the child windows of the modal window.....

Code: Select all

void Window::onKeyDown(KeyEventArgs& e)
    fireEvent(EventKeyDown, e, EventNamespace);

    // As of 0.7.0 CEGUI::System no longer does input event propogation, so by
    // default we now do that here.  Generally speaking key handling widgets
    // may need to override this behaviour to halt further propogation.
    if (!e.handled && d_parent &&
        d_parent != System::getSingleton().getModalTarget())
        e.window = d_parent;

This line:

Code: Select all

    if (!e.handled && d_parent &&
        d_parent != System::getSingleton().getModalTarget())

Stops propogating the event to its parent if it is a child window of the modal window.
According to the comments, I'm wondering whether the code should be:

Code: Select all

    if (!e.handled && d_parent &&
        this != System::getSingleton().getModalTarget())

To stop propogating right at the modal window.


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

Re: Keyboard Events on Modal Window

Postby CrazyEddie » Sat Aug 07, 2010 13:39

I believe you could be right! :) I'll have a little double-check of a couple of points and almost certainly commit the suggested fix.



Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests