Events, hooks

BlitzMax Forums/MaxGUI Module/Events, hooks

Who was John Galt?(Posted 2008) [#1]
I have a textbox connected to a slider and I want the text to display the value of the slider. I'm looking into using an event hook to update the text when the slider moves, but if I'm understanding correctly (and it is a bit hazy), the hook will be called every time an event is emitted from any GUI object. Is this correct? If so, it seems like a poor man's halfway house between polling and callbacks.


SebHoll(Posted 2008) [#2]
If so, it seems like a poor man's halfway house between polling and callbacks.

Yeah, that's basically it. You are hooking into EmitEvent which is a standard Blitz function so *any* event emitted using EmitEvent will be sent to your callback before it hits the event queue. I wouldn't really class this as a "poor man's halfway" as it means its extremely flexible, but each to their own I suppose...


Who was John Galt?(Posted 2008) [#3]
Yeah it has flexibility I suppose, but it just seems a bit inefficient. Anyway, thanks, SebHoll. You've hit 2 for 2 on my MaxGUI questions!


CASO(Posted 2008) [#4]
Is there a way to make it only emit an event with a specific gadget(s)?


Who was John Galt?(Posted 2008) [#5]
Nope- all gadgets emit events. You have to figure out which gadget emitted the event from within your hooked function and act accordingly.


Mark Tiffany(Posted 2008) [#6]
I believe that you can use SebHoll's new SetGadgetSensitivty commands to amend which events you get notified for each event, which will trim it down somewhat...


SebHoll(Posted 2008) [#7]
I believe that you can use SebHoll's new SetGadgetSensitivty commands to amend which events you get notified for each event, which will trim it down somewhat...

Although, as this only affects mouse/key events that wouldn't normally be generated anyway, probably not to the degree you want it to. Also, even if a function only currently processes one event, you should still put a few If statements in there, as it may receive more in the future, if more events are added. Better to be safe...