Page 1 of 1

question about events and GUI

Posted: Mon Jun 18, 2007 10:55 am
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

Posted: Mon Jun 18, 2007 11:17 am
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.

Posted: Mon Jun 18, 2007 12:08 pm
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 :)

Posted: Mon Jun 18, 2007 2:58 pm
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.