Update mouseEvents.md

This commit is contained in:
Robert Jelic
2022-06-20 23:05:33 +02:00
committed by GitHub
parent 989fefe330
commit 3e937033b9

View File

@@ -46,7 +46,7 @@ button:onClickUp(buttonOnRelease)
# onScroll
`onScroll(self, direction, x, y)`<br>
The computercraft event which triggers this method is `mouse_scroll`.
Any visual object can register a onScroll events.
Any visual object can register onScroll events.
Here is a example on how to add a onScroll event to your button:
@@ -61,3 +61,22 @@ function buttonOnScroll()
end
button:onScroll(buttonOnScroll)
```
# onDrag
`onDrag(self, x, y)`<br>
The computercraft event which triggers this method is `mouse_drag`.
Any visual object can register onDrag events.
Here is a example on how to add a onDrag event to your button:
```lua
local basalt = dofile("basalt.lua")
local mainFrame = basalt.createFrame("myMainFrame"):show()
local button = mainFrame:addButton("myButton"):setPosition(3,3):setSize(12,3):setText("Click"):show()
function buttonOnDrag()
basalt.debug("Someone drags me (i know i wont reposition myself)!")
end
button:onDrag(buttonOnDrag)
```