GUI window closed?
GUI window closed?
I have a GUI window and I want to detect when it is being closed with the X button. I can't find any event for this. I tried checking if the window is visible but it seems it is always visible even when it is closed .
This thread here might helps you abit - http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=10962 - Also might try searching around abits so you don't have to worry abouts possibly getting flamed.
Here's what I did to get the close message - this involves a few small additions to the engine source code , I've marked these (5 lines) with //ADD
in CGUIWindow.cpp:
So your event handler should now get a EGET_MESSAGEBOX_CANCEL message, i.e.
I don't know if there's an easier way, but this seems to work fine for me.
in CGUIWindow.cpp:
Code: Select all
bool CGUIWindow::OnEvent(SEvent event)
{
/*
Some small inclusions from CGUIMessageBox.cpp, so an event is
generated when the close button is pressed
*/
SEvent outevent; //ADD
outevent.EventType = EET_GUI_EVENT; //ADD
outevent.GUIEvent.Caller = this; //ADD
switch(event.EventType)
{
case EET_GUI_EVENT:
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST)
{
Dragging = false;
return true;
}
else
if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
{
if (event.GUIEvent.Caller == CloseButton)
{
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_CANCEL; //ADD
Parent->OnEvent(outevent); //ADD
remove();
return true;
}
}
break;
Code: Select all
if ((event.EventType == EET_GUI_EVENT) && (event.GUIEvent.EventType == EGET_MESSAGEBOX_CANCEL)) {
//do something
}