Page 1 of 1

Close button on a framewindow

Posted: Fri Oct 28, 2005 10:03
by wuack
I would appreciate it much, if someone could help me with this X-looking button on the framewindow called Close Button.

Excuse my ignorance here, :oops: but the close button seems not to close anything. I found out that the CloseButtonEnabled property is only to hide or show the button. How do i get the button to actually close the window. I can't really call an event to handle it, since it doesn't have a name.

I'm hoping there's something really easy that i just dont know about :D. I figure it should be a common feature to deal with, but i failed to find the solution in the forum. It might just have been my ignorance's fault again.:D
thanks

Re: Close button on a framewindow

Posted: Fri Oct 28, 2005 12:43
by lindquist
Subscribe to the "CloseClicked" event of the FrameWindow and do what you feel the button should do in that handler :)

HTH

Re: Close button on a framewindow

Posted: Fri Oct 28, 2005 12:45
by dsmirnov
Greetings.

This is really easy stuff.
To handle close window button (as any other button) you need to subscribe window event.

Like this example:
[size=x-small][color=0000CC][font=Arial]
using namespace CEGUI;

Window* someWindow = WindowManager::getSingleton().getWindow("SomeWindow");

someWindow->
subscribeEvent(FrameWindow::EventCloseClicked, Event::Subscriber(&AuroraGUI::handleCloseButton, this));
[/font][/color][/size]

This "handleCloseButton" function will do everything you need on pressing close window button.

I'm using following code to handle all windows close buttons:
[size=x-small][color=0000CC][font=Arial]
bool AuroraGUI::handleCloseButton(const CEGUI::EventArgs& e)
{
static_cast<const CEGUI::WindowEventArgs&>(e).window->hide();

return true;
}
[/font][/color][/size]

Re: Close button on a framewindow

Posted: Fri Oct 28, 2005 14:30
by wuack
Thanks a lot,

love love love the replies :D.

Re: Close button on a framewindow

Posted: Sat Nov 05, 2005 19:42
by wuack
:( when i t coded as suggested and got compilation error. here's that code segment:

wmgr.getWindow((CEGUI::utf8*)"Demo8/CodeWindow") ->subscribeEvent( CEGUI::FrameWindow::EventCloseClicked,
CEGUI::Event::Subscriber(&GuiApplication::handleCloseButton, this));

and here's the error,
error C2027: use of undefined type 'FrameWindow'

i can't make any sense of why FrameWindow is undefined Type. :(.

Thanks for the help.