mouse click (event)

From ComputerCraft Wiki
Revision as of 11:45, 28 June 2015 by MKlegoman357 (Talk | contribs)

Jump to: navigation, search


Grid Modem.png  Event mouse_click
Fired when the terminal of an advanced system is pressed with a mouse. Unavailable to normal systems, as these lack mouse support.
Returned Object 1 The mouse button that was clicked. Left Mouse Button is returned as the number 1, Right Mouse Button is returned as the number 2 and Middle Mouse Button is returned as the number 3
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

Grid paper.png  Example
Print the button and the co-ordinates of every mouse click we receive.
Code
while true do
  local event, button, x, y = os.pullEvent( "mouse_click" )
  
  print( "The mouse button ", button, " was pressed at ", x, " and ", y )
end
Output The button that was pressed, followed by the X and Y position of the event.