AddHook my own event

BlitzMax Forums/BlitzMax Beginners Area/AddHook my own event

Rick_72(Posted 2010) [#1]
After reading most of event-related stuff and tutorials here I tried to set up an own trigger system:

Type TTrigger
	
...

	Global _TriggerList:TList

	Method New()
		If _TriggerList = Null
			_TriggerList = New TList
			AddHook EmitEventHook, _myEventHandler
		EndIf
		_TriggerList.AddLast(Self)
	End Method

...

	Function _myEventHandler:Object(id:Int, data:Object, context:Object)
		Local ev:TEvent = TEvent(data)
		If ev.id = EVENT_TIMERTICK 

...

			EndIf
		EndIf 
	End Function

end type




Using the PollEvent command leads to the desired effect: the timers trigger my eventhandler and everything is fine.
But the combination of
AddHook EmitEventHook, .. 
and PollEvent seems to eat all other events which brings up the following issue: I can't use any other events, e.g. MouseX(). They are simply gone (polled by PollEvent).

Can I do something like:

AddHook myOwnEventHook,_myEventHandler
?

I want to prevent the handler to be called by every event emitted but only by my very own one. How can I do this?

To make it easy and precise: I want wo replace EmitEventHook by my own event hook, e.g. a timer hook. I want my eventhandler to be called only by this event hook, not by every event that occurs.

Does PollEvent delete the event queue?

And what is the third parameter worth for (Addhook ..,..,context)?


Guys, I know this is a well known issue but I couldn't find any way out. Hope someone can help me out!

Thanks!


Rick_72(Posted 2010) [#2]
OK, I could peek the event queue for the desired event ID and just polled if I find what I am looking for.
But anyways, can anyone explain the AddHook parameters, please? What is context for?


Jesse(Posted 2010) [#3]
this might help you a little:
http://www.2dgamecreators.com/maxgui/T15-Eventhooks.html


Rick_72(Posted 2010) [#4]
No, not at all. The question was about the use of an own hook instead of using the given ones like EmitHookEvent.
The standard use of hook events is absolutely clear but what about own ones and setting a context??


Compt-Man(Posted 2010) [#5]
TO hook just use extra dll file with c++ decompliler