From 3e937033b9c03c76dd5a15aa6ee3c85bf21118fc Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Mon, 20 Jun 2022 23:05:33 +0200 Subject: [PATCH] Update mouseEvents.md --- docs/events/mouseEvents.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/events/mouseEvents.md b/docs/events/mouseEvents.md index d113114..66be726 100644 --- a/docs/events/mouseEvents.md +++ b/docs/events/mouseEvents.md @@ -46,7 +46,7 @@ button:onClickUp(buttonOnRelease) # onScroll `onScroll(self, direction, x, y)`
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)`
+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) +```