LuaControl

This type represents the base for a control. It is used to create custom controls that perform any user-defined functionalities.

circle-info

This is just a control type, to learn how to create custom controls, see LuaControlProto documentation. A proper example on how to use both types can be found here.

__call๏ปฟ

Constructor

Constructs the custom control.

Arguments

Name

Type

Description

id

ControlID|string

ID.

proto

Prototype for this control

position

Custom offset

size

Custom size

Returns

Type

Description

Custom control instance.

Example

local proto = gui.LuaControlProto()

function proto:onRender(contents, _, mins, maxs)
    contents:AddRectFilled(draw.Rect(mins, maxs), draw.color.White())
end

local my_custom_control = gui.LuaControl('my_control', proto, draw.Vec2(), draw.Vec2(24, 24))

data

Field

Type: table<any>

This control's internal data, specified by initialData in LuaControlProto . Can be modified.


IsOutOfRect

Method

Checks if control is outside of a rectangle.

Arguments

Name

Type

Description

rect

The desired rectangle

Returns

Type

Description

boolean

Whether or not it is outside

Example


IsOutOfClip

Method

Checks if control is outside of a rectangle, with some tolerance.

Arguments

Name

Type

Description

rect

The desired rectangle

tolerance

number

The tolerance, in pixels

Returns

Type

Description

boolean

Whether or not it is outside

Example


Highlight

Method

Highlights the control temporarily and switches to that tab, if applicable.

Arguments

None.

Returns

Nothing.

Example


LockInput

Method

Locks all input, making sure you can't access other controls. Useful for controls you click or drag on.

circle-exclamation

Arguments

None.

Returns

Nothing.

Example


UnlockInput

Method

Unlocks all input.

Arguments

None.

Returns

Nothing.

Example


IsLockedByMe

Method

Checks if the window input is locked by this control.

Arguments

None.

Returns

Type

Description

boolean

Whether or not the window is locked by this control

Example


IsLockedByOther

Method

Checks if the window input is locked by another control.

Arguments

None.

Returns

Type

Description

boolean

Whether or not the window is locked by another control

Example


IsInputLocked

Method

Checks if the window input is locked.

Arguments

None.

Returns

Type

Description

boolean

Whether or not the window is locked

Example

Last updated