submenu

Button Callbacks

TypeScript RootPlayer Root
on_clickfunction(): voidfunction(index: int): void

Toggle Callbacks

TypeScript RootPlayer Root
on_clickfunction(state: bool): voidfunction(index: int, state: bool): void

Slider Int Callbacks

TypeScript RootPlayer Root
on_clickfunction(value: int): voidfunction(index: int, value: int): void
on_changefunction(value: int): voidfunction(index: int, value: int): void
on_click --[[w/ Toggle]]function(value: int, state: bool): voidfunction(index: int, value: int, state: bool): void
on_change --[[w/ Toggle]]function(value: int, state: bool): voidfunction(index: int, value: int, state: bool): void

Slider Float Callbacks

TypeScript RootPlayer Root
on_clickfunction(value: float): voidfunction(index: int, value: float): void
on_changefunction(value: float): voidfunction(index: int, value: float): void
on_click --[[w/ Toggle]]function(value: float, state: bool): voidfunction(index: int, value: float, state: bool): void
on_change --[[w/ Toggle]]function(value: float, state: bool): voidfunction(index: int, value: float, state: bool): void
TypeScript RootPlayer Root
on_enterfunction(): voidfunction(index: int): void
on_exitfunction(): voidfunction(index: int): void

Text Input Callbacks

TypeScript RootPlayer Root
on_submitfunction(text: string): voidfunction(index: int, text: string): void

List Callbacks

TypeScript RootPlayer Root
on_clickfunction(item: string): voidfunction(index: int, item: string): void
on_changefunction(item: string): voidfunction(index: int, item: string): void
on_click --[[w/ Toggle]]function(item: string, state: bool): voidfunction(index: int, item: string, state: bool): void
on_change --[[w/ Toggle]]function(item: string, state: bool): voidfunction(index: int, item: string, state: bool): void

Methods

is_valid

Returns true if the submenu reference is still valid

function submenu.is_valid(): bool
-- example usage
local valid = sub:is_valid()

is_focused

Returns true if the submenu is focused

function submenu.is_focused(): bool
-- example usage
local focused = sub:is_focused()

get_label

Returns the label of the submenu

function submenu.get_label(): string
-- example usage
local label = sub:get_label()

set_label

Sets the label of the submenu

function submenu.set_label(label: string): void
-- example usage
sub:set_label("Example")

add_separator

Creates and adds a separator option to the submenu and returns a reference to the option created

function submenu.add_separator(label: string): option
-- example usage
local opt = sub:add_separator("Example")

add_button

Creates and adds a button option to the submenu and returns a reference to the option created

function submenu.add_button(label: string, hints: string[], on_click: function): option
-- example usage
local opt = sub:add_button("Example", { "Example Hint" }, function()
    -- do something on click
end)

add_toggle

Creates and adds a toggle option to the submenu and returns a reference to the option created

function submenu.add_toggle(label: string, hints: string[], on_click: function): option
-- example usage
local opt = sub:add_toggle("Example", { "Example Hint" }, function(state)
    -- do something on click
end)

add_slider_int

Creates and adds a slider option to the submenu and returns a reference to the option created

function submenu.add_slider_int(label: string, initial_value: int, minimum: int, maximum: int, step: int, has_toggle: bool, hints: string[], on_click: function, on_change: function): option
-- example usage
-- w/ toggle
local opt = sub:add_slider_int("Example", 5, 1, 10, true, { "Example Hint" }, function(value, state)
    -- do something on click
end, nil)

-- w/o toggle
local opt = sub:add_slider_int("Example", 5, 1, 10, false, { "Example Hint" }, nil, function(value)
    -- do something on change
end)

add_slider_float

Creates and adds a slider option to the submenu and returns a reference to the option created

function submenu.add_slider_float(label: string, initial_value: float, minimum: float, maximum: float, step: float, has_toggle: bool, hints: string[], on_click: function, on_change: function): option
-- example usage
-- w/ toggle
local opt = sub:add_slider_float("Example", 5.0, 1.0, 10.0, true, { "Example Hint" }, function(value, state)
    -- do something on click
end, nil)

-- w/o toggle
local opt = sub:add_slider_float("Example", 5.0, 1.0, 10.0, false, { "Example Hint" }, nil, function(value)
    -- do something on change
end)

add_submenu

Creates and adds a submenu option to the submenu and returns a reference to the submenu and option created

function submenu.add_submenu(label: string, hints: string[], on_enter: function, on_exit: function): submenu, option
-- example usage
-- w/ on enter
local sub, opt = sub:add_submenu("Example", { "Example Hint" }, function()
    -- do something on enter
end, nil)

-- w/ on exit
local sub, opt = sub:add_submenu("Example", { "Example Hint" }, nil, function()
    -- do something on exit
end)

add_text_input

Creates and adds a text input option to the submenu and returns a reference to the option created

function submenu.add_text_input(label: string, initial_text: string, max_length: int, clear_before: bool, clear_after: bool, hints: string[], on_submit: function): option
-- example usage
local opt = sub:add_text_input("Example", "Initial Text", 32, true, false, { "Example Hint" }, function(text)
    -- do something on submit
end)

add_list

Creates and adds a list option to the submenu and returns a reference to the option created

function submenu.add_list(label: string, items: string[], has_toggle: bool, hints: string[], on_click: function, on_change: function): option
-- example usage
-- w/ toggle
local opt = sub:add_list("Example", { "Item 1", "Item 2" }, true, { "Example Hint" }, function(value, state)
    -- do something on click
end, nil)

-- w/o toggle
local opt = sub:add_list("Example", { "Item 1", "Item 2" }, false, { "Example Hint" }, nil, function(value)
    -- do something on change
end)

add_colour

Creates and adds a colour option to the submenu and returns a reference to the option created

function submenu.add_colour(label: string, initial_red: bool, initial_green: bool, initial_blue: bool, initial_alpha: bool, hints: string[]): option
-- example usage
local opt = sub:add_colour("Example", 1.0, 1.0, 1.0, 1.0, { "Example Hint" })