luxe: ui/control
Control
Section titled “Control”import "luxe: ui/control" for ControlClass for managing controls on UI modifiers. Note that all UI elements are controls, including UIImage, UILabel, UIButton, etc…
var ui = Entity.create(ui)UI.create(ui, 0, 0, width, height, 0, ui_camera)var control = Control.create(ui)
Control.create(.)
Section titled “Control.create(.)”Control.create(ui_entity : Entity) : ControlCreate a “blank” control for layout or custom input/drawing. Returns the new Control.
Control.create(..)
Section titled “Control.create(..)”Control.create(ui_entity : Entity, type_id : String) : ControlCreate a typed control. Returns the new Control.
Control.destroy(.)
Section titled “Control.destroy(.)”Control.destroy(control : Control) : NoneDestroy an existing control.
var control = Control.create(_ui)//do stuff and then later...Control.destroy(control)
Control.destroy_children(.)
Section titled “Control.destroy_children(.)”Control.destroy_children(control : Control) : NoneDestroy the children of a control.
Control.valid(.)
Section titled “Control.valid(.)”Control.valid(control : Control) : BoolCheck if a control exists and has not been destroyed.
var control = Control.create(_ui)Log.print(Control.valid(control)) //trueControl.destroy(control)Log.print(Control.valid(control)) //false
Control.get_ui(.)
Section titled “Control.get_ui(.)”Control.get_ui(control : Control) : EntityGet UI entity a control is part of.
var control = Control.create(_ui)var control_ui = Control.get_ui(control)Log.print(control_ui == _ui) //true
Control.get(.)
Section titled “Control.get(.)”Control.get(id : String) : ControlGet a control by its id.
var control = Control.create(_ui)Control.set_id(control, "test_id")var control_by_id = Control.get("test_id")Log.print(control == control_by_id) //true
Control.exists(.)
Section titled “Control.exists(.)”Control.exists(id : String) : BoolCheck if a control with a specific id exists.
Control.clear(..)
Section titled “Control.clear(..)”Control.clear(control : Control, uiclear_action : UIClear) : NoneClear the children of a control in a specific manner.
Control.press(..)
Section titled “Control.press(..)”Control.press(control : Control, state : Bool) : NoneSend a press or release event to the control (in the center of the control)
Control.enter(..)
Section titled “Control.enter(..)”Control.enter(control : Control, state : Bool) : NoneSend a enter or exit event to the control
Control.can_see(.)
Section titled “Control.can_see(.)”Control.can_see(control : Control) : BoolReturns true if this control can be seen, or false if clipped.
Control.can_see_area(..)
Section titled “Control.can_see_area(..)”Control.can_see_area(control : Control, area : Rect) : BoolReturns true if the area at this control can be seen or false if clipped.
Control.can_see_point(..)
Section titled “Control.can_see_point(..)”Control.can_see_point(control : Control, point : Vec) : BoolReturns true if the point at this control can be seen or false if clipped.
Control.point_inside(..)
Section titled “Control.point_inside(..)”Control.point_inside(control : Control, point : Vec) : BoolReturns true if the point is inside the bounds of the control. Ignores visibility etc.
Control.get_data(.)
Section titled “Control.get_data(.)”Control.get_data(control : Control) : BlockGet the data block for this control
Control.set_type(..)
Section titled “Control.set_type(..)”Control.set_type(control : Control, type : String) : unknownno docs found
Control.get_type(.)
Section titled “Control.get_type(.)”Control.get_type(control : Control) : unknownno docs found
Control.set_id(..)
Section titled “Control.set_id(..)”Control.set_id(control : Control, id : String) : unknownSet the id of a control. Good for debugging and retrieving controls by their id. Must be unique, so adding
ID.unique()to the id can be useful.var control = Control.create(_ui)Control.set_id(control, "good_recognizable_control_name_%(ID.unique())")
Control.get_id(.)
Section titled “Control.get_id(.)”Control.get_id(control : Control) : StringRetrieve the id of a control.
Control.get_bounds_abs(..)
Section titled “Control.get_bounds_abs(..)”Control.get_bounds_abs(control : Control, into : List) : NoneRetrieve the bounds(position and size) of a control (relative to the UI modifier) into a list
[x, y, width, height]. The passed list must have at least 4 elements and the function will write into the first 4. Passing a list into the function instead of returning a value is to avoid allocating memory where not needed.var parent = Control.create(_ui)Control.set_pos(parent, 50, 50)var child = Control.create(_ui)Control.child_add(parent, child)Control.set_pos(child, 100, 100)Control.set_size(child, 20, 20)var bounds = [0,0,0,0]Control.get_bounds_abs(child, bounds)Log.print(bounds) // [150, 150, 20, 20]
Control.get_bounds(..)
Section titled “Control.get_bounds(..)”Control.get_bounds(control : Control, into : List) : NoneRetrieve the bounds(position and size) of a control (relative to their parent control or ui modifier if there is none) into a list
[x, y, width, height]. The passed list must have at least 4 elements and the function will write into the first 4. Passing a list into the function instead of returning a value is to avoid allocating memory where not needed.var parent = Control.create(_ui)Control.set_pos(parent, 50, 50)var child = Control.create(_ui)Control.child_add(parent, child)Control.set_pos(child, 100, 100)Control.set_size(child, 20, 20)var bounds = [0,0,0,0]Control.get_bounds(child, bounds)Log.print(bounds) // [100, 100, 20, 20]
Control.set_allow_bounds_event(..)
Section titled “Control.set_allow_bounds_event(..)”Control.set_allow_bounds_event(control : Control, state : Bool) : NoneEnables bounds events for the control. Since there are many controls that may be resized during layout events, only ones that ask for the event will receive it to save time.
Control.get_allow_bounds_event(.)
Section titled “Control.get_allow_bounds_event(.)”Control.get_allow_bounds_event(control : Control) : BoolReturns true if this control sends bounds events.
Control.set_bounds_abs(…)
Section titled “Control.set_bounds_abs(…)”Control.set_bounds_abs(control : Control, x : Num, y : Num, w : Num, h : Num) : NoneSet the control bounds(position and size) relative to the UI modifier.
Control.set_bounds(…)
Section titled “Control.set_bounds(…)”Control.set_bounds(control : Control, x : Num, y : Num, w : Num, h : Num) : NoneSet the control bounds(position and size) relative to the parent control.
Control.set_pos_abs(…)
Section titled “Control.set_pos_abs(…)”Control.set_pos_abs(control : Control, x : Num, y : Num) : NoneSet the control position relative to the UI modifier.
Control.set_pos(…)
Section titled “Control.set_pos(…)”Control.set_pos(control : Control, x : Num, y : Num) : NoneSet the control position relative to the parent control, or UI modifier if no parent exists.
Control.set_system_cursor(..)
Section titled “Control.set_system_cursor(..)”Control.set_system_cursor(control : Control, cursor : SystemCursor) : NoneIf the control has input enabled, when entered it will set the system cursor to the given type.
Control.set_size(…)
Section titled “Control.set_size(…)”Control.set_size(control : Control, w : Num, h : Num) : NoneSet the control size.
Control.get_pos_x(.)
Section titled “Control.get_pos_x(.)”Control.get_pos_x(control : Control) : NumGet the control position x component relative to its parent control.
Control.get_pos_x_abs(.)
Section titled “Control.get_pos_x_abs(.)”Control.get_pos_x_abs(control : Control) : NumGet the control position x component.
Control.get_pos_y(.)
Section titled “Control.get_pos_y(.)”Control.get_pos_y(control : Control) : NumGet the control position y component relative to its parent control.
Control.get_pos_y_abs(.)
Section titled “Control.get_pos_y_abs(.)”Control.get_pos_y_abs(control : Control) : NumGet the control position y component.
Control.get_width(.)
Section titled “Control.get_width(.)”Control.get_width(control : Control) : NumGet the control width.
Control.get_height(.)
Section titled “Control.get_height(.)”Control.get_height(control : Control) : NumGet the control height.
Control.contains(…)
Section titled “Control.contains(…)”Control.contains(control : Control, x : Num, y : Num) : BoolCheck whether the a point is within the control bounds
Control.get_entity(.)
Section titled “Control.get_entity(.)”Control.get_entity(control : Control) : EntityGet the entity that has the UI modifier the control in.
Control.get_parent(.)
Section titled “Control.get_parent(.)”Control.get_parent(control : Control) : ControlGet the entity this entity is a child of or
nullif there isnt any.
Control.get_allow_input(.)
Section titled “Control.get_allow_input(.)”Control.get_allow_input(control : Control) : BoolGet whether the control recieves input events in its
set_processfunction.
Control.set_allow_input(..)
Section titled “Control.set_allow_input(..)”Control.set_allow_input(control : Control, allow : Bool) : NoneSet whether the control recieves input events in its
set_processfunction.
Control.set_allow_drag(…)
Section titled “Control.set_allow_drag(…)”Control.set_allow_drag(control : Control, allow : Bool, tag : String) : NoneSet whether the control recieves drag events
Control.set_droppable_payload(..)
Section titled “Control.set_droppable_payload(..)”Control.set_droppable_payload(control : Control, value : Handle) : NoneSet a value that will be passed through the drag event to the drop event on the other side. This value is a handle/number, so you can pass api handles, a number, a hashed string, or a block instance
Control.get_droppable_payload(.)
Section titled “Control.get_droppable_payload(.)”Control.get_droppable_payload(control : Control) : HandleGet the drop payload for this control
Control.set_droppable_tags(..)
Section titled “Control.set_droppable_tags(..)”Control.set_droppable_tags(control : Control, tags : List) : NoneSet the droppable tags that are allowed for this control, as an array of strings
Control.get_droppable_tags(.)
Section titled “Control.get_droppable_tags(.)”Control.get_droppable_tags(control : Control) : ListGet the droppable tags that are allowed for this control, as an array of strings
Control.get_attached(.)
Section titled “Control.get_attached(.)”Control.get_attached(control : Control) : EntityIf used via
luxe: system/ui/control.modifier, returns the entity this control belongs to. Entity.none is returned if not
Control.get_allow_keys(.)
Section titled “Control.get_allow_keys(.)”Control.get_allow_keys(control : Control) : BoolGet whether the control recieves key events in its
set_processfunction.
Control.set_allow_keys(..)
Section titled “Control.set_allow_keys(..)”Control.set_allow_keys(control : Control, allow : Bool) : NoneSet whether the control recieves key events in its
set_processfunction.
Control.get_allow_tab(.)
Section titled “Control.get_allow_tab(.)”Control.get_allow_tab(control : Control) : BoolGet whether the control can be “tabbed” to.
Control.set_allow_tab(..)
Section titled “Control.set_allow_tab(..)”Control.set_allow_tab(control : Control, allow : Bool) : NoneSet whether the control can be “tabbed” to.
Control.get_visible(.)
Section titled “Control.get_visible(.)”Control.get_visible(control : Control) : BoolGet whether a control is visible.
Control.set_visible(..)
Section titled “Control.set_visible(..)”Control.set_visible(control : Control, visible : Bool) : NoneSet whether a control (or its children) is visible. Note that when a control is not visible, it also doesnt contribute to the layout.
Control.get_opacity(.)
Section titled “Control.get_opacity(.)”Control.get_opacity(control : Control) : NumGet a control opacity value.
Control.set_opacity(..)
Section titled “Control.set_opacity(..)”Control.set_opacity(control : Control, opacity : Num) : NoneSet a control opacity value. Affects children opacity as well.
Control.get_disabled(.)
Section titled “Control.get_disabled(.)”Control.get_disabled(control : Control) : BoolGet whether a control is disabled. This refers to the “inputable” state of inputs like buttons or text fields.
Control.set_disabled(..)
Section titled “Control.set_disabled(..)”Control.set_disabled(control : Control, disabled : Bool) : NoneSet whether a control is disabled. This refers to the “inputable” state of inputs like buttons or text fields.
Control.get_enabled(.)
Section titled “Control.get_enabled(.)”Control.get_enabled(control : Control) : BoolGet whether a control is enabled. This refers to the “inputable” state of inputs like buttons or text fields.
Control.set_enabled(..)
Section titled “Control.set_enabled(..)”Control.set_enabled(control : Control, enabled : Bool) : NoneSet whether a control is enabled. This refers to the “inputable” state of inputs like buttons or text fields.
Control.get_clip(.)
Section titled “Control.get_clip(.)”Control.get_clip(control : Control) : BoolGet whether a control should clip its contents.
Control.set_clip(..)
Section titled “Control.set_clip(..)”Control.set_clip(control : Control, clip : Bool) : NoneSet whether a control should clip its contents.
Control.get_nodes(.)
Section titled “Control.get_nodes(.)”Control.get_nodes(control : Control) : NumGet how many child controls this control has recursively. So 1 if it doesnt have any children, 2 if it has 1 child, 3 if it has 2 children or if it has 1 child which itself has a child, etc… Only valid after
UI.commit.
Control.get_depth(.)
Section titled “Control.get_depth(.)”Control.get_depth(control : Control) : NumGet the depth generated for a control, not including the depth offset.
Control.get_depth_offset(.)
Section titled “Control.get_depth_offset(.)”Control.get_depth_offset(control : Control) : NumGet the depth offset of a control.
Control.set_depth_offset(..)
Section titled “Control.set_depth_offset(..)”Control.set_depth_offset(control : Control, depth_offset : Num) : NoneSet the depth offset for a control, allowing you to move it in front or behind other controls if the generated depth doesnt work for you
Control.get_input_inside(.)
Section titled “Control.get_input_inside(.)”Control.get_input_inside(control : Control) : BoolCheck whether the input (usually mouse cursor) is currently in a control. (In sync with
UIEvent.enterandUIEvent.exit)
Control.get_input_pressed(.)
Section titled “Control.get_input_pressed(.)”Control.get_input_pressed(control : Control) : BoolCheck whether the input (usually mouse cursor) is currently in a control and any of its buttons are pressed.
Control.child_at_point(…)
Section titled “Control.child_at_point(…)”Control.child_at_point(control : Control, x : Num, y : Num) : ControlGet the top child control at a specific (absolute) point.
Control.child_count(.)
Section titled “Control.child_count(.)”Control.child_count(control : Control) : NumGet the amount of children a control has.
Control.child_index(..)
Section titled “Control.child_index(..)”Control.child_index(control : Control, child : Control) : NumGet the index of a child control.
Control.child_get(..)
Section titled “Control.child_get(..)”Control.child_get(control : Control, index : Num) : ChildGet a child control by its index.
Control.child_add(…)
Section titled “Control.child_add(…)”Control.child_add(control : Control, child : Control, internal : Bool) : NoneMake a control the child control of another control. If you mark the child as internal, it wont be queried by other methods affecting children.
Control.child_add(..)
Section titled “Control.child_add(..)”Control.child_add(control : Control, child : Control) : NoneMake a control the child control of another control. This means the childs position will be relative to its parent, layout depends a lot on those relationships and its used by functions like destroy_children.
//create parentvar parent = Control.create(_ui)Control.set_bounds(parent, 200, 200, 100, 100)//create childvar child = Control.create(_ui)Control.set_bounds(child, 25, 25, 50, 50)//parent child to parentControl.child_add(parent, child)var bounds = [0,0,0,0]Control.get_bounds_abs(child, bounds)Log.print(bounds) //[225, 225, 50, 50]Control.clear(parent, UIClear.destroy)Log.print(Control.child_count(parent)) //0Log.print(Control.valid(child)) //falseUI.commit(_ui)
Control.child_remove(..)
Section titled “Control.child_remove(..)”Control.child_remove(control : Control, child : Control) : NoneRemove a child from a control, unparenting it.
Control.children_bounds(..)
Section titled “Control.children_bounds(..)”Control.children_bounds(control : Control, into : List) : NoneGet the combined bounds of all children of a control into a list
[x, y, width, height]. The passed list must have at least 4 elements and the function will write into the first 4. Passing a list into the function instead of returning a value is to avoid allocating memory where not needed.
Control.set_behave(..)
Section titled “Control.set_behave(..)”Control.set_behave(control : Control, behave : UIBehave) : NoneSet how the control behaves in the layout as a child of its container. You can combine characteristics with a bit or operator (
|).
Control.get_behave(.)
Section titled “Control.get_behave(.)”Control.get_behave(control : Control) : UIBehaveReturns the behave bitflags for the control
Control.set_contain(..)
Section titled “Control.set_contain(..)”Control.set_contain(control : Control, contain : UIContain) : NoneSet how the control behaves in the layout as a container of its children. You can combine characteristics with a bit or operator (
|).
Control.get_contain(.)
Section titled “Control.get_contain(.)”Control.get_contain(control : Control) : UIContainReturns the contain bitflags for the control
Control.set_margin(…)
Section titled “Control.set_margin(…)”Control.set_margin(control : Control, left : Num, top : Num, right : Num, bottom : Num) : NoneSet the margins of a control. Only the margins set in
set_behaveare actually observed.
Control.set_limits(…)
Section titled “Control.set_limits(…)”Control.set_limits(control : Control, min_x : Num, min_y : Num, max_x : Num, max_y : Num) : NoneSet the min and max size of a control when using layout.
Control.get_margin(.)
Section titled “Control.get_margin(.)”Control.get_margin(control : Control) : ListGet the margins of a control.
Control.set_render(..)
Section titled “Control.set_render(..)”Control.set_render(control : Control, fn : Fn) : NoneSet a custom render function with the arguments
|control, state, x, y, w, h|. Useful for making your own controls.
Control.set_events(..)
Section titled “Control.set_events(..)”Control.set_events(control : Control, fn : Fn) : StringAdd a function to handle events on a control. Returns an
idfor the newly added event that can be used to remove it.var btn = UIButton.create(ui)UIButton.set_text(btn, "click me!")Control.set_events(btn) {|event|if(event.type == UIEvent.release) {Log.print("clicked button")}}
Control.unset_events(.)
Section titled “Control.unset_events(.)”Control.unset_events(control : Control) : NoneRemove all event handling functions from a control.
Control.unset_events(..)
Section titled “Control.unset_events(..)”Control.unset_events(control : Control, id : String) : NoneRemove an event handling function from a control. Takes in the id that was returned upon registering the function.
Control.set_process(..)
Section titled “Control.set_process(..)”Control.set_process(control : Control, fn : Fn) : NoneSet a custom process function with the arguments
|control, state, event, x, y, w, h|. Useful for making your own controls.
Control.get_state_data(.)
Section titled “Control.get_state_data(.)”Control.get_state_data(control : Control) : AnyGet the state data associated with this control.
Control.set_state_data(..)
Section titled “Control.set_state_data(..)”Control.set_state_data(control : Control, data : Any) : NoneSet state data associated with this control. Can be any wren object.
Control.data(.)
Section titled “Control.data(.)”Control.data(control : Control) : AnyGet the data block for this control