mouse_click event

From ComputerCraft
Jump to: navigation, search
mouse_click
Event
Returns
  • button : number The mouse button that was pressed
  • x : number The X position of the mouse in the term
  • y : number The Y position of the mouse in the term

Source CC:Tweaked

Occurs every time a mouse button is pressed.

Note Note: This event is only called on advanced terms, such as an Advanced Computer, Advanced Pocket Computer or Neural Interface.

ExampleExamplePrint coordinates
Prints the mouse coordinates and button name every time a mouse button is pressed.
Code
local button_names = { [1] = "left", [2] = "right", [3] = "middle" }

while true do
  local event, button, x, y = os.pullEvent("mouse_click")
  print("The", button_names[button], "mouse button has been pressed at", x, ",", y)
end