Event Hooks - capturing all events?

BlitzMax Forums/BlitzMax Programming/Event Hooks - capturing all events?

ImaginaryHuman(Posted 2008) [#1]
Background: I am using an `event hook` to capture all o/s input from the user. I am calling `Driver.Poll()` which polls for events and calls the event hook if one happens. My single event hook function basically checks for several interesting events using a Select-Case statement, and then does something appropriate depending on the event. Presumably I don't really need to return the event from the hook because I only have one hook (Mark said in another thread that you only need return the event object if you have multiple hooks), but I do default to returning it if it's not one that I make any use of.

Question: If, since the last Poll(), the user has triggered three operating system events, and then I do Driver.Poll() once, will my event hook function be called three times, or do I need to call Driver.Poll() three times to get all three events?

I can't seem to even figure out how to make a test program to see how this works - I could only get one event to seem to show per Poll, and other events seemed to be getting ignored completely?


ImaginaryHuman(Posted 2008) [#2]
Bumpety bump..


Kurator(Posted 2008) [#3]
.Poll() gives you the next Event in the Event Queue

From Help:
Function PollEvent()

Returns The id of the next event in the event queue, or 0 if the event queue is empty
Description Get the next event from the event queue
Information PollEvent removes an event from the event queue and updates the CurrentEvent global variable.

If there are no events in the event queue, PollEvent returns 0.

So simply loop your poll unless you geht a 0 returned, to be sure to get all events catched


ImaginaryHuman(Posted 2008) [#4]
Are you sure Driver.Poll() does the same thing as PollEvent()?

I was thinking along similar lines, that maybe Driver.Poll() only gets one event, and maybe I need to go up a level in function calls.


Kurator(Posted 2008) [#5]
If I go down i.e. to system.win32.c, it calls 2 functions in a while loop for all system messages:

1.) translate_message()
2.) dispatch_message()

I did not investigate further, but it is obvious for me, that it puts it on the brl event queue - so maybe you should really go up a level :)


ImaginaryHuman(Posted 2008) [#6]
I knew there was a reasony why Driver.Poll() was faster than the higher level commands ;-) I guess I'll just have to call PollSystem.