Event on close

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
grantkrieger
Posts: 25
Joined: Fri Jul 27, 2007 10:02 am

Event on close

Post 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
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
horvim
Posts: 11
Joined: Thu Aug 30, 2007 2:08 pm
Location: Hungary

Post 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!
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

In the latest svn version a new gui-event called EGET_ELEMENT_CLOSED was added. This can be used.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
horvim
Posts: 11
Joined: Thu Aug 30, 2007 2:08 pm
Location: Hungary

Post 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.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
horvim
Posts: 11
Joined: Thu Aug 30, 2007 2:08 pm
Location: Hungary

Post by horvim »

Oh. I got it. Thanks!
Keep on waiting for the final 1.4 version :wink:
Post Reply