Update mouseEvents.md

This commit is contained in:
Robert Jelic
2022-06-20 23:06:44 +02:00
committed by GitHub
parent 3e937033b9
commit 9858bce3f6

View File

@@ -32,12 +32,12 @@ local basalt = dofile("basalt.lua")
local mainFrame = basalt.createFrame("myMainFrame"):show() local mainFrame = basalt.createFrame("myMainFrame"):show()
local button = mainFrame:addButton("myButton"):setPosition(3,3):setSize(12,3):setText("Click"):show() local button = mainFrame:addButton("myButton"):setPosition(3,3):setSize(12,3):setText("Click"):show()
function buttonOnClick() function buttonOnClick(self, button, x, y)
basalt.debug("Button got clicked!") basalt.debug("Button got clicked!")
end end
button:onClick(buttonOnClick) button:onClick(buttonOnClick)
function buttonOnRelease() function buttonOnRelease(self, button, x, y)
basalt.debug("Button got released!") basalt.debug("Button got released!")
end end
button:onClickUp(buttonOnRelease) button:onClickUp(buttonOnRelease)
@@ -56,14 +56,14 @@ local basalt = dofile("basalt.lua")
local mainFrame = basalt.createFrame("myMainFrame"):show() local mainFrame = basalt.createFrame("myMainFrame"):show()
local button = mainFrame:addButton("myButton"):setPosition(3,3):setSize(12,3):setText("Click"):show() local button = mainFrame:addButton("myButton"):setPosition(3,3):setSize(12,3):setText("Click"):show()
function buttonOnScroll() function buttonOnScroll(self, direction, x, y)
basalt.debug("Someone scrolls on me!") basalt.debug("Someone scrolls on me!")
end end
button:onScroll(buttonOnScroll) button:onScroll(buttonOnScroll)
``` ```
# onDrag # onDrag
`onDrag(self, x, y)`<br> `onDrag(self, button, x, y)`<br>
The computercraft event which triggers this method is `mouse_drag`. The computercraft event which triggers this method is `mouse_drag`.
Any visual object can register onDrag events. Any visual object can register onDrag events.
@@ -75,7 +75,7 @@ local basalt = dofile("basalt.lua")
local mainFrame = basalt.createFrame("myMainFrame"):show() local mainFrame = basalt.createFrame("myMainFrame"):show()
local button = mainFrame:addButton("myButton"):setPosition(3,3):setSize(12,3):setText("Click"):show() local button = mainFrame:addButton("myButton"):setPosition(3,3):setSize(12,3):setText("Click"):show()
function buttonOnDrag() function buttonOnDrag(self, button, x, y)
basalt.debug("Someone drags me (i know i wont reposition myself)!") basalt.debug("Someone drags me (i know i wont reposition myself)!")
end end
button:onDrag(buttonOnDrag) button:onDrag(buttonOnDrag)