GRID CARTOGRAPHER 4
Shortcuts

UITextCursor

2019-04-12

This helper class adds support for a text mode mouse cursor.

Requirements

Header | uikit/textcursor.nut

Methods

Create

UITextCursor.Create(): void

Create the singleton instance of the UITextCursor class. During creation the number of display columns will be stored, so make sure to set the correct display mode prior to calling.

Destroy

UITextCursor.Destroy(): void

Destroy the singleton instance of the UITextCursor class.

Hide

UITextCursor.Hide(): void

Hide the cursor. Always call this when drawing to the display to prevent graphical corruption.

Moved

UITextCursor.Moved(): bool

Returns true if the cursor has moved (or left/entered the screen) since the last call to Update.

Show

UITextCursor.Show(): void

Show the cursor again if it's hidden.

State

UITextCursor.State(): table|null

Returns the state of the cursor. If the cursor is off-screen or hidden the class method returns null, otherwise it returns a table with the following slots:

Key Value
x:int The x position of the cursor in characters (relative to the top-left of the console)

Note: Manual scrolling of the console is ignored. Using GCConsole.ScrollEnable is not recommend.
y:int The y position of the cursor in characters (relative to the top-left of the console).
b:int If the left mouse button is pressed/held, bit 0 is set.
If the right mouse button is pressed/held, bit 1 is set.
If the middle mouse button is pressed/held, bit 2 is set.
click:int Trigger bits for mouse buttons. Will set bits corresponding to the mouse button that was just clicked.
rel:int Release trigger bits for mouse buttons. Will set bits corresponding to the mouse button that was just released.

Update

UITextCursor.Update(): void

Update the text cursor internal state and draw it on the screen.