Page 1 of 1

Close button function

Posted: Sat Aug 27, 2011 01:48
by RoboWarrior
I want to close a framewindow from the X button but it doesn't work

Code: Select all

CEGUI::FrameWindow* finestra = static_cast<CEGUI::FrameWindow*>(wmgr.createWindow("TaharezLook/FrameWindow"));
finestra->setSize(CEGUI::UVector2(CEGUI::UDim(0.3, 0), CEGUI::UDim(0.4, 0)));
finestra->setText("Status");
finestra->setCloseButtonEnabled(true);
finestra->subscribeEvent(CEGUI::FrameWindow::EventCloseClicked,CEGUI::Event::Subscriber(&GUIStatus::CloseButton, this));
sheet->addChildWindow(finestra);


the function is:

Code: Select all

bool GUIStatus::CloseButton(const CEGUI::EventArgs&)
{
   finestra->setVisible(false);
   return true;// error
}


but it give me an exeption on the return true; statement.
What I have to do? thankyou

Re: Close button function

Posted: Sat Aug 27, 2011 07:33
by Kulik
You have to:
1) Read guidelines
2) Follow them

Not enough info to answer.

Re: Close button function

Posted: Mon Aug 29, 2011 15:43
by Jamarr
As Kulik said it is very important for users to follow the Forum Usage Guidelines. These guidelines are there for your benefit. Following these increases the probability that 1) a community will spend their free time looking into your issue and 2) a community member can actually solve or help you solve the issue. In this particular case, it would have been helpful for you to post your CEGUI.log file as well as the callstack (with debug symbols on) when the exception is thrown. Since you did not provide this information, it will be more difficult for us to diagnose it and thus we are less likely to figure out the issue and thus are less likely to afford you any help at all.

That being said, I will just throw out a guess here and say that finestra is either undefined or incorrectly defined. I very much doubt that return true is throwing an exception. In the most likely case, the debugger is merely stopping on the line after the exception was thrown giving the illusion that return true is at fault.

Re: Close button function

Posted: Sun Sep 11, 2011 00:22
by maori
Heya

one thing i would suggest is that dont use the setvisable as if yo want to reopen that window you could end up with an exception allready exsists but i'am just getting my head around this again so may be tottally wrong but i use the following function for my x button

Code: Select all

bool myUI::CloseWindowButton(const CEGUI::EventArgs& e)
{
static_cast<const CEGUI::WindowEventArgs&>(e).window->destroy();
return true;
}


and the button code i use is

Code: Select all

exit->subscribeEvent(FrameWindow::EventCloseClicked, Event::Subscriber(&myUI::CloseWindowButton, this));


hope it helps