Page 1 of 1

How to detect which window was closed

Posted: Sat Oct 25, 2008 01:47
by yamashi
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

Posted: Sat Oct 25, 2008 13:57
by scriptkid
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.

Posted: Sat Oct 25, 2008 17:41
by yamashi
Thanks !

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

Thanks again !

Posted: Sun Oct 26, 2008 09:40
by scriptkid
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 :)