How to detect which window was closed

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

yamashi
Just popping in
Just popping in
Posts: 7
Joined: Sat Oct 25, 2008 01:43

How to detect which window was closed

Postby yamashi » Sat Oct 25, 2008 01:47

Hi !

I am trying to detect on which frameWindow I have to close when the close button is pressed...

Here is my code :

Code: Select all

                PopUp = (FrameWindow*)Wmgr->createWindow ("TaharezLook/FrameWindow");
                MenuBackground->addChildWindow(PopUp);
                PopUp->setMinSize(UVector2(UDim(0,200),UDim(0,100)));
                PopUp->setText("Error");
                PopUp->setCloseButtonEnabled(true);
                PopUp->subscribeEvent(
            CEGUI::FrameWindow::EventCloseClicked,
            CEGUI::Event::Subscriber(&GuiApplication::handleWindowClose, this));


And the close function :

Code: Select all

    bool handleWindowClose(const CEGUI::EventArgs& e)
    {
        MenuBackground->removeChildWindow(PopUp);
        return true;
    }


Thanks

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Sat Oct 25, 2008 13:57

Hi and welcome :)

to know which window hits an event, you can cast the given argument:

Code: Select all

Window* window = static_cast<Window*>(static_cast<const WindowEventArgs&>(e).window;


HTH.
Check out my released snake game using Cegui!

yamashi
Just popping in
Just popping in
Posts: 7
Joined: Sat Oct 25, 2008 01:43

Postby yamashi » Sat Oct 25, 2008 17:41

Thanks !

I knew it was going to be that e but didn't find anything usefull in the doc...

Thanks again !

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Sun Oct 26, 2008 09:40

Hi,

glad it works now!

I knew it was going to be that e but didn't find anything usefull in the doc...


If it's not in the docs, it might be in the sample code :)
Check out my released snake game using Cegui!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 19 guests