Community Project: BlitzMax Examples in Helpfiles

BlitzMax Forums/BlitzMax Programming/Community Project: BlitzMax Examples in Helpfiles

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.

The use of Superstrict might not be mandatory, but I actually think it's best to teach things the right way. Esp. for beginners, Superstrict helps finding bugs. (also for the medium/advanced :P)

some alternatives:
SuperStrict
Rem

'
' EventSource()
'
' Gives the object where an event has been emitted from.
'

Local window:tgadget=CreateWindow("events",0,0,320,240)

Local button1:tgadget=CreateButton("Button1",4,4,80,24,window)
Local button2:tgadget=CreateButton("Button2",84,4,80,24,window)

Repeat
	WaitEvent()
	If EventID()=EVENT_WINDOWCLOSE End
	
	Select EventSource()
		Case button1 Print "button1"
		Case button2 Print "button2"
	End Select
	
Forever

'
' EventId()
'
' Gives the ID of the event that has just been emitted.
'

Local window:tgadget=CreateWindow("events",0,0,320,240)

Local button:tgadget=CreateButton("Button1",4,4,80,24,window)
Local canvas:tgadget=CreateCanvas(84,4,80,24,window,1)

Repeat
	WaitEvent()
	If EventID()=EVENT_WINDOWCLOSE End
	
	Select EventID()
		Case EVENT_GADGETACTION Print "gadgetaction (buttonpress, etc.)"
		Case EVENT_MOUSEMOVE Print "canvas mousemove"
	End Select
	
Forever

'
' EventData()
'
' Gives the data field (an int value) of the event that has just been emitted.
'

Local window:tgadget=CreateWindow("leftclick/rightclick",0,0,320,240)

Local canvas:tgadget=CreateCanvas(4,4,160,160,window,1)

Repeat
	WaitEvent()
	If EventID()=EVENT_WINDOWCLOSE End
	
	Select EventData()
		Case 1 Print "leftclick"
		Case 2 Print "rightclick"
	End Select
Forever


'
' EventX()
'
' Gives the X field (an int value) of the event that has just been emitted.
'

Local window:tgadget=CreateWindow("move mouse",0,0,320,240)

Local canvas:tgadget=CreateCanvas(4,4,160,160,window,1)

Repeat
	WaitEvent()
	If EventID()=EVENT_WINDOWCLOSE End
	
	If EventID()=EVENT_MOUSEMOVE
		Print EventX()
	EndIf
Forever


'
' EventY()
'
' Gives the Y field (an int value) of the event that has just been emitted.
'

Local window:tgadget=CreateWindow("move mouse",0,0,320,240)

Local canvas:tgadget=CreateCanvas(4,4,160,160,window,1)

Repeat
	WaitEvent()
	If EventID()=EVENT_WINDOWCLOSE End
	
	If EventID()=EVENT_MOUSEMOVE
		Print EventY()
	EndIf
Forever


'
' EventText$()
'
' Gives the text$ field (converted from the EXTRA field) of the event that has just been emitted.
'

Local window:tgadget=CreateWindow("move mouse",0,0,320,240,Null,15|WINDOW_ACCEPTFILES)

Repeat
	WaitEvent()
	If EventID()=EVENT_WINDOWCLOSE End
	
	If EventID()=EVENT_WINDOWACCEPT
		Print EventText()
	EndIf
Forever

EndRem