Cursor

Back


Picotron includes some basic functions to take power of the cursor, the main being mouse() and window{}'s use of the cursor.
To make use of the cursor, you can access the cursor's data through mouse().

This can be seen through:
curs={}
curs.x, curs.y, curs.b, curs.wheelx, curs.wheely = mouse()


Along with this, you can set the x,y position of the mouse with mouse(x,y)
This has been reported buggy and not fully functional however, an alternative with more control is seen later.

The appearance of the cursor can be changed with window{} (seen in windows) through:
window{cursor=(podded sprite, integer <sprite index>, "pointer", "grab", "dial","edit", "crosshair")}

e.g: Setting the cursor to a podded sprite
window{cursor=--[[pod_type="gfx"]]unpod("b64:bHo0ADcAAAA6AAAA8QhweHUAQyAQEATwNgEAAbABBwEHEZABBwIAE4AIAPAHcBFHAWABBwFHAXABVwGAATcBoDHwJg==")}

e.g: Setting the cursor to be invisible
window{cursor=0}

e.g: Setting the cursor to a pointer (hovering over something clickable)
window{cursor="pointer"}

Setting the mouse's specific position and button input data can be done directly through send_message() by triggering the backend of how the mouse works, allowing you to inject your own cursor information

It's best to use this with a wrapper function such as:
function setMouse(x,y,b)
send_message(3,{event="mouse",mx=x,my=y,mb=b or 0})
end

This will allow you to set the exact position of the cursor alongside the button of the mouse (left click, right click, middle click)
e.g: Set the cursor to be at the center of the screen, left clicking

setMouse(240,270,1)

A lua form of these can be downloaded below

Download