Assigning a function reference to a type field.

BlitzMax Forums/BlitzMax Programming/Assigning a function reference to a type field.

I was wondering if it was possible to set a field within a type that I can then associate with a function and call using that field. This would make my programs much more OOP, and solve a few problems I'm having. This is the kind of thing (in part) I'm trying to do:

Zone.bmx
Type t_zone
Field x1#,x2#,y1#,y2#
Field on_rightclick     '***************this is the field I'd like to use later for the function reference
Global r_ZoneList:TList


'* Create Zone **

	Method Create (a1#,a2#,b1#,b2#,fun1)
			Local temp_zone:t_zone = New t_zone
			temp_zone.x1 = a1
			temp_zone.x2 = a2
			temp_zone.y1 = b1
			temp_zone.y2 = b2
			temp_zone.on_rightclick = fun1 '***********This reference seems to compile fine.
			If r_ZoneList = Null Then r_ZoneList = CreateList()
			r_ZoneList.AddLast(temp_zone)

	End Method
'********************** Check Zones ******************

	Function CheckZones()
		For Local test:t_zone = EachIn r_ZoneList
			test.Check(MouseX(),MouseY(),MouseHit(1))
		Next
	End Function	
	
'********************** Check ************************

	Method Check(a#,b#,but1)
		Local To_return:Int = 0
		If a>= x1 And a<= x2 And b>= y1 And b<= y2 Then
			If but1 >0 Then Local g = self.on_rightclick '******************This doesn't work!!!

		End If
	End Method

End Type


Main.bmx
Strict
Include "Zone.bmx"

Graphics 800,600


Global c_Zone:t_zone = New t_zone
c_zone.Create(0,20,0,20,LabelIt())

While (Not KeyHit(KEY_ESCAPE))

Cls
t_zone.CheckZones()

Flip
Wend

Function LabelIt()
	DrawText ("Activated",MouseX(),MouseY())
End Function

The program compiles fine unless I try to reference the function in Check(). I'm guessing that I'm assigning a pointer to "on_rightclick" in the Create() Method, but I don't know how to call the function associated with it (unless I should be declaring on_rightclick as an object? Pointer? something else?)

Any help would be .... errr .... helpful.