How to detect IGUIWindow's close button pressed?
How to detect IGUIWindow's close button pressed?
I want to handle the event when a window is closed with the built-in close button, but can't seem to find a suitable method. Is it possible to do so without modifying Irrlicht itself?
Regarding to me you haven't to modify Irrlicht,
but however you have to include a private header (CGUIWindow.h).
This is a bit uncomfortable if someone wants recompiling your
application and he has only irrlicht public headers.
then when you want to create a catchable window:
bye
but however you have to include a private header (CGUIWindow.h).
This is a bit uncomfortable if someone wants recompiling your
application and he has only irrlicht public headers.
Code: Select all
#include "CGUIWindow.h"
class MyWindow : public CGUIWindow
{
public:
MyWindow (irr::gui::IGUIEnvironment *env, irr::gui::IGUIElement *e,
irr::s32 id, irr::core::rect<irr::s32> rect) :
CGUIWindow (env, e, id, rect) {}
bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_GUI_EVENT &&
event.GUIEvent.EventType == irr::gui::EGET_BUTTON_CLICKED &&
event.GUIEvent.Caller == this -> getCloseButton ()) {
printf ("catched!\n");
}
return CGUIWindow::OnEvent (event);
}
};
Code: Select all
IGUIWindow *w = new MyWindow(guienv, guienv->getRootGUIElement(),
-1, irr::core::rect<s32> (0, 0, 320, 240));
w->setText(L"test window");