What I am trying to do is following:
Code: Select all
myproto_obj = {}
Function myproto_obj:New()
Local d = {}
SetMetaTable(d, self)
self.__index = self
Return(d)
EndFunction
function myproto_obj.LeftMouseDown(msg)
debugprint("default leftmousedown")
endfunction
function myproto_obj:AssignFuncToLeftMouseDown(func)
self.LeftMouseDown = Func
endfunction
function func1 ()
debugprint("func1")
endfunction
MyObj = myproto_obj:New()
MakeButton(Nil, #SIMPLEBUTTON, 100, 100, 1000, 1000, {OnMouseDown=MyObj.LeftMouseDown})
MyObj:AssignFuncToLeftMouseDown(func1)
waitevent()
MyObj:LeftMouseDown()
However, what happens is that from event activation it prints "default leftmousedown" and then from the last line the expected "Func1"
Hence, indeed it does copy the new function (func1) on top of the old "myobj.leftmousedown" function, but when the button makes a call, instead of referencing towards the current "MyObj:LeftMouseDown" it is still referring to the old one, i suppose to "Myproto_obj.LeftMouseDown" function.
Is there a way to make makebuttons evt_table to go to the most current myobj.leftmousedown function, or do i have to make two functions to get it done? ie.
Code: Select all
function myobj.letfmousedown(msg)
myobj.therealleftmousedown(msg)
endfunction
function myobj.therealleftmousedown(msg)
debugprint("default left mouse down")
endfunction
function func1()
debugprint("func1")
endfunction
myobj.therealleftmousedown = func1