Some handy non-MaxGui event code

BlitzMax Forums/BlitzMax Programming/Some handy non-MaxGui event code

I just wrote this:

Strict

Graphics 800,600,0

Local EventList: TList = New TList

While Not KeyHit(KEY_ESCAPE)

	Cls
	
	DrawText "Press <Escape> or click the window X to close",0,0
			
	Flip

	EventList.Clear()	
	'Check all the events in the queue and react to any that we need to.
	While PeekEvent()
		PollEvent()
		Select EventID()
			Case EVENT_APPTERMINATE
				End
			Default
				'we didn't use it so store it
				EventList.AddLast(CurrentEvent)
		End Select
	Wend
	
	'Now post the events back.
	For Local E:TEvent = EachIn EventList
		PostEvent(E)
	Next
Wend

which seems to be a good way to trap Window events yet still let the normal blitz code handle key presses and mouse events. Thought I'd share and see if anyone can improve it as I may not be using it in the best way. Anyway seems to work well for me.

You can avoid an extra call by doing this:

	While PollEvent()
		Select EventID()
			Case EVENT_APPTERMINATE
				End
			Default
				'we didn't use it so store it
				EventList.AddLast(CurrentEvent)
		End Select
	Wend


Thx btw, very handy piece of code.

Oh OK, cool thanks so I don't need to peek it first I guess.

Hi
It's a pity that it doesn't send the EVENT_WINDOWMOVE event. Blitzsupport??
This could be a more handy event code, Grey Alien.

Strict 

Graphics 800,600,0


Function Hook:Object(id:Int, Data:Object, Context:Object)
	Local Event:TEvent
	
	Event = TEvent(Data)
	
	Select Event.id
		Case EVENT_WINDOWMOVE
			Print "WINDOWMOVE"
			' GIVE MEEEE THIIIIS EVEEEENNNNT

		Case EVENT_MOUSEDOWN
			Print "MOUSEDOWN"
		
		Case EVENT_MOUSEUP
			Print "MOUSEUP"
			
		
	End Select 
End Function


AddHook EmitEventHook, Hook


Repeat 
	Cls
	SetClsColor Rand(0,255), Rand(0,255), Rand(0,255)
	

	Flip
Until KeyHit(KeY_ESCAPE)


Mfg

IT STILL DOES NOT!!!
...and I can't seem to find an explanation either... lol

Would someone care to say a tiny something?

...and I can't seem to find an explanation either... lol
An explanation why it doesn't work?

IT STILL DOES NOT!!!
BRL has a nack for not doing stuff.

Yup...percisely! No idea what the idea is behind events, if they only cover somethings under some circumstances...
why would maxgui permit getting mousemove events, but without maxgui it won't...
There's always that off chance that I just don't know something...lol
..no wait, that's the given! 8)))

MaxGUI is *separate*, if you will, from BlitzMax (in the sense that it is a module). MaxGUI stuff is it's own, afaik there could be a workaround for changing WM messages into events, but that's only windows; in the past Mark didn't add some features simply because they weren't cross-platform.