Difference between revisions of "Mouse scroll (event)"
From ComputerCraft Wiki
(Created event page.) |
(Added example.) |
||
| Line 7: | Line 7: | ||
|return2=The X-coordinate of the scroll (in screen-characters). | |return2=The X-coordinate of the scroll (in screen-characters). | ||
|return3=The Y-coordinate of the scroll (in screen-characters). | |return3=The Y-coordinate of the scroll (in screen-characters). | ||
| + | |examples= | ||
| + | {{Example | ||
| + | |desc=Print the direction and the co-ordinates of every mouse scroll we receive a ''mouse_scroll'' event for. | ||
| + | |code= | ||
| + | while true do | ||
| + | scrollDirection, xPos, yPos = os.pullEvent("[[mouse_scroll_(event)|mouse_scroll]]") | ||
| + | [[print]]("mouse_scroll: " .. [[tostring]](scrollDirection) .. ", " .. | ||
| + | "X: " .. [[tostring]](xPos) .. ", " .. | ||
| + | "Y: " .. [[tostring]](yPos)) | ||
| + | end | ||
| + | |output=The direction the mouse-wheel was scrolled in, followed by the X and Y position of the event. | ||
| + | }} | ||
}} | }} | ||
Revision as of 00:34, 1 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 15:57, 30 November 2012 (MSK)) |
Examples
| Print the direction and the co-ordinates of every mouse scroll we receive a mouse_scroll event for. | |
| Code |
while true do
scrollDirection, xPos, yPos = os.pullEvent("mouse_scroll")
print("mouse_scroll: " .. tostring(scrollDirection) .. ", " ..
"X: " .. tostring(xPos) .. ", " ..
"Y: " .. tostring(yPos))
end
|
| Output | The direction the mouse-wheel was scrolled in, followed by the X and Y position of the event. |