Events in Irrlicht

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
onEnterFrame
Posts: 7
Joined: Sun Dec 05, 2010 8:34 am

Events in Irrlicht

Post by onEnterFrame »

me again. ill probably be posting a lot more of these annoying questions until i either figure everything out or give up.


at the moment im a bit confused how irrlicht event handling works. i DO understand this:

- an IEventReciever can be passed to the Irrlicht device when it is created. i understand how to get input from this sort of source and how to process it.

but if this is the only event processor for irrlicht, how do cameras like FPS cameras, get their even input? how do gui elements receive events?

it seems like the programmer can only register ONE event receiver for the entire application. is there a way to add multiple event receivers? is this just so horribly inefficient that it's never done?

because its certainly simpler.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You have one user receiver at a time. You can exchange it if you want to swap event handling. Or, which is often better, pass your events from the main receiver to child receivers. These will handle the input depending on the global situation found and decided upon in the main receiver.
The Irrlicht elements, such as cameras and GUI, get the events in case your main receiver returns false. This should be the default in all receivers. Events which are not yet handled (i.e. have a false as return value) will be passed on until they are either handled, or reach the end of the handler queue.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

The order is as follows:
Mouse&Keyboard Event is created in device->run() or log-events whenever a log-message is called.
Then the user eventreceiver is called.
Next the gui-environment gets to them (gui will also create GUI-events which then again get passed to the user eventreceiver).
Last the InputReceivingSceneManager or the SceneManager gets the events.

Events get passed on as long as no one catches them (returning true). So as long as you return false in the receiver they continue to be passed around.
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
onEnterFrame
Posts: 7
Joined: Sun Dec 05, 2010 8:34 am

Post by onEnterFrame »

thanks. i think its pretty clear now. ill probably write a generalized event dispatcher tonight or whenever im less lazy
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

onEnterFrame wrote:thanks. i think its pretty clear now. ill probably write a generalized event dispatcher tonight or whenever im less lazy
I wrote one a long time ago, so maybe that still works:
http://irrlicht.sourceforge.net/phpBB2/ ... ntreceiver
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
Post Reply