Is it possible to use self in evt_table functions?

Discuss any general programming issues here
Post Reply
Bugala
Posts: 759
Joined: Sun Feb 14, 2010 7:11 pm

Is it possible to use self in evt_table functions?

Post by Bugala » Tue Jul 18, 2017 6:04 am

This isnt the only situation where I have encountered this problem, but just as example.

Suppose I am making a button, so i make:

Code: Select all

makebutton(1, #LAYERBUTTON, "brushname", false, false, evt_table)
Problem is the evt_table part.

Suppose i have a function:

Code: Select all

function myfunc:changeX
self.x = mousex()
endfunction 
but now when i try to use it on evt_table:

Code: Select all

evt_table={OnMouseDown = myfunc:changeX}
it doesnt work.

Is there a way to access a self function in situation like this, or am i forced to not use self in situations like this?

User avatar
airsoftsoftwair
Posts: 3027
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Is it possible to use self in evt_table functions?

Post by airsoftsoftwair » Sat Jul 22, 2017 2:28 pm

I'm afraid but that isn't supported at the moment. You can emulate it using the userdata parameter, though.

Bugala
Posts: 759
Joined: Sun Feb 14, 2010 7:11 pm

Re: Is it possible to use self in evt_table functions?

Post by Bugala » Sat Jul 22, 2017 4:23 pm

to wish list then.

Post Reply