Reading the most recent Event from Event Queue

BlitzMax Forums/BlitzMax Programming/Reading the most recent Event from Event Queue

Hi,

Does anybody know how to read the last event to be posted in the event queue? I don't need the next event in the queue, but the last one: the one most recently added.

I need to check if an event has been added and remove it from the queue but if events have happened before it was triggered, I can't use PeekEvent() or PollEvent().

Cheers


Seb

Can you use Postevent with the Update=TRUE option?
Maybe you could update it , somehow, to be ignored.
Having said that I'm not sure what you're after. Do you know the eventid and eventsource?
Just thinking out aloud.
I tried to see what postevent was doing.
There are 255 slots on the event queue so I wondered whether you could loop, saving the previous, until you hit null. Might be a tricky task if events are being added all the time (e.g. timerticks etc).

tonyg: Your idea about PostEvent with Update=True was a good idea. I didn't know it could be done, but unfortunately, I can't use it to stop the event triggering.

To give you a better idea, I have an event hook which detects if a window is being moved, rounds the windows position to the nearest 5 (like snap to grid) and moves the window to the rounded co-ordinates using the SetGadgetShape() command. However, using this command generates another EVENT_WINDOWMOVE, which is rounded, repositioned and relocated using SetGadgetShape(), which generates another EVENT_WINDOWMOVE etc. etc. Anyway, you end up with a window jumping all over the place as soon as it enters this cyclic mess.

So I need to stop the EVENT_WINDOWMOVE from firing when I call SetGadgetLayout() or kill the event, before the event handler get's its hands on it.

You can just flag the event you fire yourself, and then ignore it if it's flagged :)
If event.id = EVENT_WINDOWMOVE
	If event.data <> -1000
		' .. do something ..
		
		' post a flagged event
		PostEvent( CreateEvent(EVENT_WINDOWMOVE,bla,-1000,0,modifiedx,modifiedy) )
	EndIf
EndIf
Or maybe not?

Alternatively you can test if the x and y position is already ok, and then do nothing if they are.