padicao2010 wrote:Function updateMouse needs position (x,y), which may not be calculated comfortably.
You don't need to calculate it, because you already know it. Either you have provided it yourself:
Code: Select all
suit.Button("Click?", 100,100, 150,30)
or you can note the cell coordinates from the layout:
Code: Select all
local x,y,w,h = suit.layout:row()
suit.Button("Click?", x,y,w,h)
All you have to do is maintain the currently keyboard-"hovered" item and fake the mouse position to that item, e.g.
Code: Select all
local x,y,w,h
x,y,w,h = suit.layout:row()
if keyboard_hovered == "button-1" then suit.updateMouse(x,y) end
suit.Button("This", {id = "button-1"}, x,y,w,h)
x,y,w,h = suit.layout:row()
if keyboard_hovered == "button-2" then suit.updateMouse(x,y) end
suit.Button("is", {id = "button-2"}, x,y,w,h)
x,y,w,h = suit.layout:row()
if keyboard_hovered == "button-3" then suit.updateMouse(x,y) end
suit.Button("untested", {id = "button-3"}, x,y,w,h)
How you switch the active item and what you count as mouse click is up to you.