Events and Hooks documentation

BlitzMax Forums/BlitzMax Programming/Events and Hooks documentation

tonyg(Posted 2006) [#1]
Documentation on how to use Events and Hooks seems to be missing any detail. For example...


Function CreateEvent:TEvent( id,source:Object=Null,data=0,mods=0,x=0,y=0,extra:Object=Null )
Returns A new event object.
Description Create an event object.



Parms are not self-explanatory.

another example is..
Function AddHook( id,func:Object( id,data:Object,context:Object ),context:Object=Null,priority=0 )



tonyg(Posted 2006) [#2]
Ahh, fantastic!
Moved from the Bug Forum to the BlitzMax Programming forum.
So, I assume it's being left up to somebody else to explain what all these parms do, provide an example of their use but it doesn't need to be documented.
Anybody?


ImaginaryHuman(Posted 2006) [#3]
Each TEvent object has these fields included - the data, mods, x and y coords if relevant, etc. and any extra data I guess is in the extra object. I agree it is initially underdocumented.


tonyg(Posted 2006) [#4]
AngelDaniel, thanks for the response.
So what does/can/should source,data, mods, x, y and extra contain?
When you say "initially underdocumented" do you mean there is more documentation available somewhere else?
What about the AddHook parms?
Anybody?
(rant mode on) BRL has given you this task as they feel the documentation is adequate to know what to do which these functions. Is everybody saying that, perhaps, the documentation is not useable in this case? If you're not, then please help explain what the parms are for.
{rant mode off}
Anyway, I know a few people will suggest that, instead of moaning, I behave like a good community member and work this out for myself and provide feedback.
It's just this lack of respect from BRL gets on my nads.


Dreamora(Posted 2006) [#5]
The documentation is useless.
But you know ... Assassari's great tutorials aren't there for fun :D
*If I were him, I would have asked them for some money for this job ... he is keeping their asses from beeing kicked for a craptastic un-documetation*


tonyg(Posted 2006) [#6]
I agree. If it wasn't for Assari's MaxGUI tutorials the MaxGUI product would have been next to useless for me.
In fact, if it wasn't for Wave's Beginner's Guide and a few of the others I would have given up using Bmax or, at least, not appreciated how good Bmax language is.
I bought Bmax (and B2D, B3D) because they take a lot of the legwork out of programming. If, in Bmax case, I have to read the source code before understanding the 'helper' functions then it's a bit counter-productive.
Anyway, back to the case in point....
Who is confident they know how to use each of the Event/Hook parms and can provide examples?


Dreamora(Posted 2006) [#7]
I will try a short explanation of the params:

source: Object that fired the event.

data: Event data that is given. Its usage varies on the different events. The hotkey event for example packs in the used key (on CTRL-V it would be KEY_V)

mods: Additional data (modifier data). Its usage varies as well. hotkey event saves here the MODIFIER key that fired the event. (on CTRL-V it would be MODIFIER_CONTROL)

x,y: Used for EVENT_MOUSEMOVE - current mouse position. On an own event, you could fill it with what you like (collision position for example)

extra: does normally not contain anything. But it is powerfull for own events as this is the only field beside source that accepts objects. I use especially this one on my currently in-dev module as it provides much power (and data to tell the handling routine what type of object is saved in it)


The event descriptions normally contain the information on which fields are used.
Most fields are normally not used (source,data are the commonly used, mods and x,y on some special events)

If you create your own events, it is up to you what you pack in them ... they can be used for quite a lot of absurd stuff ;-)


skidracer(Posted 2006) [#8]
CreateEvent is used for internal puposes, I wouldn't encourage it's use but the fields of TEvent are listed albeit briefly.

As for the hook module, it's a generic system for calling a bunch of function pointers (you can use it for whatever you want).

What you use data and context references for besides the documented FlipHook(which doesn't use them) and MaxGUI (see the RedrawGadget example) is up to you.


tonyg(Posted 2006) [#9]
thanks Skid. I could have spent days just getting to that point.
It's a shame that CreateEvent is not encouraged as it was something I spent a long time understanding and seemed pretty powerful. I thought events and hooks were closely linked and made some sort of 'Fire and forget' processing.
If I understand what you're saying then the hook mechanism is a 'chain' of functions. It appears that 'data' is used in RunHooks to pass information to the next hook function in the chain.


ImaginaryHuman(Posted 2006) [#10]
The MaxGUI documentation is pretty okay mostly but I do think it could do with some extra explaining in parts, some of it is just a bit too simple and vague. But otherwise it's cool. :-)