Difference between revisions of "Mouse drag (event)"
From ComputerCraft Wiki
m (Updated error with only listing two event parameters, and not three.) |
|||
Line 4: | Line 4: | ||
|name=mouse_drag | |name=mouse_drag | ||
|desc=Fired when the mouse is dragged (implies that a [[mouse_click_(event)|mouse_click]] event has already occurred). | |desc=Fired when the mouse is dragged (implies that a [[mouse_click_(event)|mouse_click]] event has already occurred). | ||
− | |return1=The | + | |return1=The mouse button that was clicked. |
− | | | + | |return2=The X-coordinate of the click (in screen-characters). |
+ | |return3=The Y-coordinate of the click (in screen-characters). | ||
|examples= | |examples= | ||
{{Example | {{Example | ||
Line 12: | Line 13: | ||
while true do | while true do | ||
_, button, xPos, yPos = os.pullEvent("[[mouse_drag_(event)|mouse_drag]]") | _, button, xPos, yPos = os.pullEvent("[[mouse_drag_(event)|mouse_drag]]") | ||
− | [[print]]("mouse_drag: X: " .. [[tostring]](xPos) .. ", " .. | + | [[print]]("mouse_drag => " .. tostring(button) .. ": " .. |
+ | "X: " .. [[tostring]](xPos) .. ", " .. | ||
"Y: " .. [[tostring]](yPos)) | "Y: " .. [[tostring]](yPos)) | ||
end | end | ||
|output=The X and Y position of the mouse during the drag. | |output=The X and Y position of the mouse during the drag. | ||
− | |||
}} | }} | ||
}} | }} |
Revision as of 11:22, 27 December 2012
This page needs some serious TLC, stat! Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: A demonstration on the use and handling of this event would be beneficial. AfterLifeLochie 16:00, 30 November 2012 (MSK)) |
Event mouse_drag | |
Fired when the mouse is dragged (implies that a mouse_click event has already occurred). | |
Returned Object 1 | The mouse button that was clicked. |
Returned Object 2 | The X-coordinate of the click (in screen-characters). |
Returned Object 3 | The Y-coordinate of the click (in screen-characters). |
Examples
Example | |
Print the new co-ordinates of the mouse every time a mouse_drag event occurs. | |
Code |
while true do _, button, xPos, yPos = os.pullEvent("mouse_drag") print("mouse_drag => " .. tostring(button) .. ": " .. "X: " .. tostring(xPos) .. ", " .. "Y: " .. tostring(yPos)) end |
Output | The X and Y position of the mouse during the drag. |