Page 1 of 1

Event on close

Posted: Wed Aug 29, 2007 5:58 am
by grantkrieger
Hello,

I have many key stroke and gui events setup. Is there an event one can call when someone trys to close the application.

Many thanks

grant

Posted: Wed Aug 29, 2007 7:32 am
by vitek
No. There is no Irrlicht event generated when the application window is closed [by clicking the [X] or pressing ALT+F4]. When this happens, the device->run() call in the main loop will return false, and you can detect that.

Code: Select all

while (device->run())
{
  if (driver->beginScene(true, true, 0))
  {
    smgr->drawAll();
    driver->endScene();
  }
}

// you can post a message to the device if you need to

device->drop();
I'm not sure what exactly you are trying to do, but with this scheme, you might not be able to cleanly do what you want. i.e. if you want to prompt the user 'are you sure you want to exit', the window might already be unloaded, or something like that.

If you want to know the app is exiting before anything else does, you'll probably have to implement a message pump [see the Win32Window example] and respond to the quit message.

Travis

Posted: Fri Sep 07, 2007 8:57 pm
by horvim
I have an FPS camera. When I click on something I call

Code: Select all

 if ( camera )
camera->setInputReceiverEnabled ( !camera->isInputReceiverEnabled() );
Then the camera is "disabled" and a subwindow opens.
And I'd like to activate the camera again, when I close this subwindow. How is it possible? What's the name of the event, when I click on the 'X' on the subwindow?
Thanks in advance!

Posted: Fri Sep 07, 2007 10:23 pm
by CuteAlien
In the latest svn version a new gui-event called EGET_ELEMENT_CLOSED was added. This can be used.

Posted: Fri Sep 07, 2007 10:46 pm
by horvim
What you mean in the latest svn version?
I have Irrlicht 1.3.1 EGET_ELEMENT_FOCUSED, EGET_ELEMENT_FOCUS_LOST, EGET_ELEMENT_HOVERED,EGET_ELEMENT_LEFT are available.

Posted: Fri Sep 07, 2007 11:02 pm
by hybrid
The latest *SVN* version is from SVN. So you have to fetch the code with a SVN client and recompile the library. That way you can test recent features which will be part of the next release 1.4 in advance of its official publication.

Posted: Sat Sep 08, 2007 1:30 pm
by horvim
Oh. I got it. Thanks!
Keep on waiting for the final 1.4 version :wink: