Skip to content

submenu


Button Callbacks

Type Script Root Player Root
on_click - int index

Toggle Callbacks

Type Script Root Player Root
on_click bool state int index, bool state

Slider Int Callbacks

Type Script Root Script Root (w/ Toggle) Player Root Player Root (w/ Toggle)
on_click int value int value, bool state int index, int value int index, int value, bool state
on_change int value int value, bool state int index, int value int index, int value, bool state

Slider Float Callbacks

Type Script Root Script Root (w/ Toggle) Player Root Player Root (w/ Toggle)
on_click float value float value, bool state int index, float value int index, float value, bool state
on_change float value float value, bool state int index, float value int index, float value, bool state

Type Script Root Player Root
on_enter - int index
on_exit - int index

Text Input Callbacks

Type Script Root Player Root
on_submit string text int index, string text

List Callbacks

Type Script Root Script Root (w/ Toggle) Player Root Player Root (w/ Toggle)
on_click string item string item, bool state int index, string item int index, string item, bool state
on_change string item string item, bool state int index, string item int index, string item, bool state

is_valid

bool submenu.is_valid()

Returns true if the submenu reference is still valid
Example Usage
local valid = sub:is_valid()

is_focused

bool submenu.is_focused()

Returns true if the submenu is focused
Example Usage
local focused = sub:is_focused()

get_label

string submenu.get_label()

Returns the label of the submenu
Example Usage
local label = sub:get_label()

set_label

void submenu.set_label(string label)

Sets the label of the submenu
Example Usage
sub:set_label("Example")

add_separator

option submenu.add_separator(string label)

Creates and adds a separator option to the submenu and returns a reference to the option created
Example Usage
local opt = sub:add_separator("Example")

add_button

option submenu.add_button(string label, string[] hints, function on_click)

Creates and adds a button option to the submenu and returns a reference to the option created
Example Usage
local opt = sub:add_button("Example", { "Example Hint" }, function()
    -- do something on click
end)

add_toggle

option submenu.add_toggle(string label, string[] hints, function on_click)

Creates and adds a toggle option to the submenu and returns a reference to the option created
Example Usage
local opt = sub:add_toggle("Example", { "Example Hint" }, function(state)
    -- do something on click
end)

add_slider_int

option submenu.add_slider_int(string label, int initial_value, int minimum, int maximum, int step, bool has_toggle, string[] hints, function on_click, function on_change)

Creates and adds a slider option to the submenu and returns a reference to the option created
Example Usage
-- w/ toggle
local opt = sub:add_slider_int("Example", 5, 1, 10, 1, 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, 1, false, { "Example Hint" }, nil, function(value)
    -- do something on change
end)

add_slider_float

option submenu.add_slider_float(string label, float initial_value, float minimum, float maximum, float step, bool has_toggle, string[] hints, function on_click, function on_change)

Creates and adds a slider option to the submenu and returns a reference to the option created
Example Usage
-- w/ toggle
local opt = sub:add_slider_float("Example", 5.0, 1.0, 10.0, 1.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, 1.0, false, { "Example Hint" }, nil, function(value)
    -- do something on change
end)

add_submenu

submenu, option submenu.add_submenu(string label, string[] hints, function on_enter, function on_exit)

Creates and adds a submenu option to the submenu and returns a reference to the submenu and option created
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

option submenu.add_text_input(string label, string initial_text, int max_length, bool clear_before, bool clear_after, string[] hints, function on_submit)

Creates and adds a text input option to the submenu and returns a reference to the option created
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

option submenu.add_list(string label, string[] items, bool has_toggle, string[] hints, function on_click, function on_change)

Creates and adds a list option to the submenu and returns a reference to the option created
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

option submenu.add_colour(string label, bool initial_red, bool initial_green, bool initial_blue, bool initial_alpha, string[] hints)

Creates and adds a colour option to the submenu and returns a reference to the option created
Example Usage
local opt = sub:add_colour("Example", 1.0, 1.0, 1.0, 1.0, { "Example Hint" })