onMouseOver Events
Posted: Sun Mar 17, 2013 10:32 pm
Hi all,
I am new here and I have trouble with the docs. Everyones help has been greatly appreciated.
I am wondering how to implement JavaScript like onMouseOver events.
I don't think I will have any trouble detecting an onMouseOver condition. I will just poll the mouse x,y and see what it is over but I will have trouble regestering events to objects.
by way of some psuedo code -
This is fine for something simple but if would get too tedious too fast when there are a large number of objects / buttons.
I have two questions -
1) How do I pass a refference to an 'object' using it's name space -
2) How do I pass a refference to a 'function' using it's name space -
I don't actualy need name space for the called function name. It would be fine if I could just put the functions into a numericly indexed array.
If need be I can just put mx,my in the global scope.
Can love go this far ???
I am new here and I have trouble with the docs. Everyones help has been greatly appreciated.
I am wondering how to implement JavaScript like onMouseOver events.
I don't think I will have any trouble detecting an onMouseOver condition. I will just poll the mouse x,y and see what it is over but I will have trouble regestering events to objects.
by way of some psuedo code -
Code: Select all
button1 = {minx = 100, maxx = 200, miny = 100, maxy = 200, onmousover = 'button1mo'}
button2 = {minx = 100, maxx = 200, miny = 300, maxy = 400, onmousover = 'button2mo'}
buttons = {button1, button2}
I have two questions -
1) How do I pass a refference to an 'object' using it's name space -
Code: Select all
button1 = {minx = 100, maxx = 200, miny = 100, maxy = 200, onmousover = 'button1mo'}
button2 = {minx = 100, maxx = 200, miny = 300, maxy = 400, onmousover = 'button2mo'}
buttons = {}
for x=1, 2 do
buttons[] = ??? 'button' .. x - to achieve the same as the code in the box above
end
Code: Select all
function button1mo(mx, my)
-- do something
end
-- execute onMouseOver event for button1
function do_any_onMouseOver(button_number) -- button number is 1
object = buttons[button_number]
funct_name = object.onmouseover
??? call function named button1mo(mx, my)
end
If need be I can just put mx,my in the global scope.
Can love go this far ???