Close button function

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

RoboWarrior
Just popping in
Just popping in
Posts: 4
Joined: Sat Aug 27, 2011 01:45

Close button function

Postby RoboWarrior » Sat Aug 27, 2011 01:48

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

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Close button function

Postby Kulik » Sat Aug 27, 2011 07:33

You have to:
1) Read guidelines
2) Follow them

Not enough info to answer.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Close button function

Postby Jamarr » Mon Aug 29, 2011 15:43

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.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

maori
Just can't stay away
Just can't stay away
Posts: 161
Joined: Tue Sep 23, 2008 13:05
Location: Plumstead , UK

Re: Close button function

Postby maori » Sun Sep 11, 2011 00:22

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
trying to upgrade to 0.8.2 from 0.7.9 :D


Return to “Help”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 14 guests