Posted 25 December 2012 - 10:11 AM
Hello,
this tutorial shall teach the very basics about the mouse events.
Note: For this tutorial you need to know how os.pullEvent() works and what events are.
If you don't, you can look it up here:
Wiki
Forum post
mouse_click
Triggers whenever someone clicks in the screen.
If it was a leftclick the first argument is 1, else it is 2.
X and y obviously are where the user clicked
Example:
Example Use: Clickable Button
mouse_drag
Triggers whenever someone clicks and holds a mousebutton in the screen.
Keeps triggering as long as the mouse button is held.
If it was a leftclick the first argument is 1, else it is 2.
X and y are where the user clicked/the mouse was while the button was held down.
Example:
Example Use: Painting/Games
mouse_scroll
Triggers whenever someone uses the mousewheel while the mouse is in the screen.
The first argument tells in which direction the user scrolled; -1 is up and 1 is down.
X and y are where the mouse was as the user scrolled.
Example:
Example Use: Scrolling text ._.
this tutorial shall teach the very basics about the mouse events.
Note: For this tutorial you need to know how os.pullEvent() works and what events are.
If you don't, you can look it up here:
Wiki
Forum post
mouse_click
Spoiler
Arguments: Left-/Rightclick (1/2), x, yTriggers whenever someone clicks in the screen.
If it was a leftclick the first argument is 1, else it is 2.
X and y obviously are where the user clicked
Example:
event,arg,x,y = os.pullEvent("mouse_click")
term.setCursorPos(x,y)
write("X")
Example Use: Clickable Button
mouse_drag
Spoiler
Arguments: Left-/Rightclick (1/2), x, yTriggers whenever someone clicks and holds a mousebutton in the screen.
Keeps triggering as long as the mouse button is held.
If it was a leftclick the first argument is 1, else it is 2.
X and y are where the user clicked/the mouse was while the button was held down.
Example:
event,arg,x,y = os.pullEvent("mouse_drag")
term.setCursorPos(x,y)
write("X")
Example Use: Painting/Games
mouse_scroll
Spoiler
Arguments: Up/Down (-1/1), x, yTriggers whenever someone uses the mousewheel while the mouse is in the screen.
The first argument tells in which direction the user scrolled; -1 is up and 1 is down.
X and y are where the mouse was as the user scrolled.
Example:
event,arg,x,y = os.pullEvent("mouse_scroll")
term.setCursorPos(x,y)
write("X")
term.scroll(arg)
Example Use: Scrolling text ._.