events

BlitzMax Forums/BlitzMax Beginners Area/events

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'm trying to figure out things like eventhooks 'n stuff.. can someone explain it a bit, for example by adding such a mechanism to the small example-source below?
So, the idea is that I don't need that t.ev in the mainloop anymore, everything should become transparent, just like the standard built-in GUI objects..
It should also emit some new events I could read out with EventSource()..

MaxGUI really needs more examples.., as good as B+ was, as minimalistic/sober MaxGUI is .. ._.

Strict

Type test

	Field canvas:TGadget
	
	Method ev()
		If EventSource()=canvas
			If EventID()=EVENT_MOUSEENTER
				update 1
			EndIf
			If EventID()=EVENT_MOUSELEAVE
				update
			EndIf
			If EventID()=EVENT_GADGETPAINT
				update
			EndIf
		EndIf
	End Method

	Method update(state:Byte=0)
		SetGraphics CanvasGraphics(canvas)
			SetClsColor 128+state*127,128+state*127,128+state*127
			Cls
		Flip
	End Method

End Type

Function createtest:test(parent:TGadget)
	Local a:test=New test
	a.canvas=CreateCanvas(32,32,48,24,parent)
	Return a
End Function

Local win:TGadget=CreateWindow("o_O",0,0,640,480)

Local t:test=createtest(win)

Repeat
	WaitEvent()
	t.ev
	If EventID()=EVENT_WINDOWCLOSE End
Forever