struct CrystGLFW::Window::Cursor
- CrystGLFW::Window::Cursor
- Struct
- Value
- Object
Overview
A Cursor represents a GLFW cursor and can either use a custom image or a system-default shape as its likeness.
Cursors are created indirectly through windows, and are therefore always associated with a Window
.
Defined in:
crystglfw/windows/cursor.crInstance Method Summary
-
#in_window?
Returns true if the cursor is in its window.
-
#position : NamedTuple()
Returns the position of the cursor relative to its window.
-
#position=(pos : NamedTuple())
Alternate syntax for
#set_position
. -
#set_position(x : Number, y : Number)
Sets the cursor's position relative to its window.
-
#window : Window
Returns the cursor's window.
Instance Method Detail
Returns true if the cursor is in its window. False otherwise.
if window.cursor.in_window?
puts "The cursor is in its window!"
else
puts "The cursor is somewhere else"
end
NOTE This method must be called from within a CrystGLFW#run
block definition.
Returns the position of the cursor relative to its window.
cp = cursor.position
puts "The cursor position is located at (#{cp[:x]}, #{cp[:y]}) relative to its window."
NOTE This method must be called from within a CrystGLFW#run
block definition.
Alternate syntax for #set_position
.
# Set the cursor position to the top-left corner of its window.
cursor.position = {x: 0, y: 0}
This method accepts the following arguments:
- pos, the desired coordinates of the cursor's position.
NOTE This method must be called from within a CrystGLFW#run
block definition.
Sets the cursor's position relative to its window.
# Set the cursor position to the top-left corner of its window.
cursor.set_position 0, 0
This method accepts the following arguments:
- x, the desired x coordinate of the cursor.
- y, the desired y coordinate of the cursor.
NOTE This method must be called from within a CrystGLFW#run
block definition.
Returns the cursor's window.
# Get the cursor's associated window.
window = cursor.window