question about events and GUI

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
eneru
Posts: 40
Joined: Tue Apr 10, 2007 8:38 am

question about events and GUI

Post by eneru »

Hi :)

i would like to know how the events work with the built in GUI, as each iguielement has a method onEvent.... => are all events re-sent to the whole GUI "tree" ? or are the GUI events the only one who are re-sent ?? (ie, if there is a keyboard event, i hope it isn't sent everywhere in the GUI unless it was made on a GUI element)

I need to know this to decide whether i use this onEvent method in each GUI element to define their behavior, or if i should better concentrate them all in one big method (which might be better for performances, but if the events go down the GUI elements tree anyway there isn't much point anymore ;))


thanks
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Usually each iguielement gets the events it needs itself. But they are all send to the eventreceiver, which is where you get them as user of the library. I don't think performance is of much concern here. Doing too much in one method is never good.
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
eneru
Posts: 40
Joined: Tue Apr 10, 2007 8:38 am

Post by eneru »

ok, so i better handle them in each of my GUI classes ? it will be indeed more easier for me (and much, much clearer), though i wanted to be sure that it would not be less efficient than one big event receiver :)
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

it's up to you... keyboard events are passed to the focused element, if they don't absorb it then they will usually pass it to their parent, and so on up the stack to the root of the gui.
if no elements have absorbed the event, it will be passed all the way back up to the user event receiver.
from a performance point of view, events and switch blocks aren't something you need to worry about - worry more about keeping your code neat.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply