Difference between revisions of "Mouse click (event)"
From ComputerCraft Wiki
(Created event page) |
(Included an example.) |
||
Line 1: | Line 1: | ||
− | |||
− | |||
{{Event | {{Event | ||
|name=mouse_click | |name=mouse_click | ||
Line 7: | Line 5: | ||
|return2=The X-coordinate of the click (in screen-characters). | |return2=The X-coordinate of the click (in screen-characters). | ||
|return3=The Y-coordinate of the click (in screen-characters). | |return3=The Y-coordinate of the click (in screen-characters). | ||
+ | |examples= | ||
+ | {{Example | ||
+ | |desc=Print the button and the co-ordinates of every mouse click we receive a ''mouse_click'' event. | ||
+ | |code= | ||
+ | while true do | ||
+ | button, xPos, yPos = os.pullEvent() | ||
+ | [[print]]("mouse_click: " .. [[tostring]](button) .. ", " .. | ||
+ | "X: " .. [[tostring]](xPos) .. ", " .. | ||
+ | "Y: " .. [[tostring]](yPos)) | ||
+ | end | ||
+ | |output=The button that was pressed, followed by the X and Y position of the event. | ||
+ | }} | ||
}} | }} |
Revision as of 00:29, 1 December 2012
Examples
Example | |
Print the button and the co-ordinates of every mouse click we receive a mouse_click event. | |
Code |
while true do button, xPos, yPos = os.pullEvent() print("mouse_click: " .. tostring(button) .. ", " .. "X: " .. tostring(xPos) .. ", " .. "Y: " .. tostring(yPos)) end |
Output | The button that was pressed, followed by the X and Y position of the event. |