Display an on-screen text
OnScreenText(x: number = 0, y: number = 0, w: number = -1, h: number = -1, fullscreen: bool = false)
Construct a OnScreenText
| Parameters | |
| x | The x coordinate of the top left point |
| y | The y coordinate of the top left point |
| w | Width of the text region. -1 for dynamic resize. Default: -1 |
| h | Height of the text region. -1 for dynamic resize. Default: -1 |
| fullscreen | Allow the OST to go fullscreen and out of bound. Default: false |
OnScreenText(region: Region, fullscreen: bool = false)
Construct a OnScreenText
| Parameters | |
| region | The region of the OST. |
| fullscreen | Allow the OST to go fullscreen and out of bound. Default: false |
static void off()
Remove all OnScreenText
number getX()
Get the x coordinate of the top left point
| Return | |
| number | The x coordinate of the top left point |
number getY()
Get the y coordinate of the top left point
| Return | |
| number | The y coordinate of the top left point |
number getW()
Get the region's width
| Return | |
| number | The region's width |
number getH()
Get the region's height
| Return | |
| number | The region's height |
string getText()
Get the current text
| Return | |
| string | The current text |
number getTextColor()
Get the current text color
| Return | |
| number | The current text color |
number getBackgroundColor()
Get the current background color
| Return | |
| number | The current text color |
Region getRegion()
Get the region of this OnScreenText. The coordinates are from the user's screen so noScale is true by default.
This will return null if the OnScreenText is not drawed on the screen yet (immediately after show() is called for the first time or off() is called). Make sure to handle null properly
| Return | |
| Region | The region of this OnScreenText |
number getClickState()
Get the click state. Only if clickable is true. There are 2 possible states: 0 - not click and 1 - clicked. The click state will be 1 after the user clicked the OnScreenText
If the state is 1 then it will auto revert back to 0 after you call this method
| Return | |
| number | The click state: 0 - not click; 1 - clicked |
number getMoveState()
Get the move state. Only if moveable is true. There are 2 possible states: 0 - not move; 1 - moving and 2 - moved. The state will have a value of 1 when the user is dragging the OnScreenText and 2 when the user releases
If the state is 2 then it will auto revert back to 0 after you call this method
| Return | |
| number | The move state: 0 - not move; 1 - moving; 2 - moved |
number getResizeState()
Get the resize state. Only if resizable is true. There are 2 possible states: 0 - not resize and 1 - resized. The resize state will be 1 after the user finish resize the OnScreenText
If the state is 1 then it will auto revert back to 0 after you call this method
| Return | |
| number | The resize state: 0 - not resize and 1 - resized |
OnScreenText setX(x: number)
Set the x coordinate of the top left point
| Parameters | |
| x | The x coordinate of the top left point |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText setY(y: number)
Set the x coordinate of the top left point
| Parameters | |
| y | The y coordinate of the top left point |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText setW(w: number)
Set the width of this region
| Parameters | |
| w | Width of the region |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText setH(h: number)
Set the width of this region
| Parameters | |
| h | Height of the region |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText setText(text: string)
Set the text to show. Basic html is supported
| Parameters | |
| text | The text to show |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText setTextColor(color: number | string | Color)
Set the text color
| Parameters | |
| color | The color of the text. null for default |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText setBackgroundColor(color: number | string | Color)
Set the background color
| Parameters | |
| color | The color of the background. null for default |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText setBackgroundImage(name: string)
Set the background image. This will override background color and vice versa.
| Parameters | |
| name | Name of the image |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText setTextSize(size: number)
Set the text size. The size is in dp
| Parameters | |
| size | The size of the text |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText moveable(moveable: bool)
Set whether this OnScreenText can be touched and moved by the user
| Parameters | |
| moveable | true to allow touch |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText clickable(clickable: bool)
Set whether this OnScreenText can be touched and clicked by the user
| Parameters | |
| clickable | true to allow touch |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText resizable(resizable: bool)
Set whether this OnScreenText can be touched and resized by the user
| Parameters | |
| resizable | true to allow touch and resize |
| Return | |
| OnScreenText | This OnScreenText instance |
OnScreenText noScale()
After calling this, the system will not attempt to scale the text region and just use the coordinate as it is
| Return | |
| OnScreenText | This OnScreenText instance |
void show()
Show this OnScreenText. Call this again to update the content
OnScreenText hidden(hidden: bool)
Set whether this OnScreenText should be hidden. This is not the same as off(). The element is still on the screen but hidden and all touch is passed through
off() will remove the view from the screen, calling show() again will reset its position if the user has moved the view with moveable() on. If you want to temporary hide the view, use this instead of off()
| Parameters | |
| hidden | true to hide the view and let touch pass through |
| Return | |
| OnScreenText | This OnScreenText instance |
void off()
Remove this OnScreenText
© 2025 - Macrorify by KoK-CODE