Doc - gui - Button


Class: Button

Inherits from: UiElement

UI button

Constructor

pos.gui.Button(x: number, y: number, w: number, h: number, background: number|nil, foreground: number|nil, text: string, onClick: function|nil)

Creates a button at the given location with given width and height.
If background or foreground is nil, they are set as the defaults: colors.gray and colors.white respectively.
onClick is called when the button is clicked with the mouse and is given the mouse button.

Variables

Type Name Description
number bg Background color
number fg Foreground color (text color)
string text Button text
function onClick Callback for button click
string type Override. type is 'Button'

Instance Functions

Return Name Description
nil draw(window: Window) Override. Draws the button
nil process(event: table, window: Window) Override. Processes mouse_click events