Widget

Methods
150
Fields
None

Getting one

chatboxPanelManager:getContainerWidget()
client:getScriptActiveWidget()
client:getFocusedInputFieldWidget()

Methods

MethodReturnsDescription
getId()numberThe packed component id, (group << 16) | component; a dynamic widget's is its component's.
getIndex()numberThe slot in the component's children, -1 for a component.
getType()numberThe widget type (WidgetType).
setType(number)()Sets the widget type.
getContentType()numberThe content type.
setContentType(number)WidgetSets the content type.
getClickMask()numberThe click mask (WidgetConfig flags) the widget itself carries.
setClickMask(number)WidgetSets the click mask.
isIf3()booleanWhether the widget is an IF3 (scripted) widget.
getParent()Widget?The parent widget, or nil (a root of the top-level interface, or an interface that is not open). A dynamic widget's parent is its compone…
getParentId()numberThe parent's id: the widget's own parent component, else the component its interface is mounted on, else -1.
getChild(number)Widget?Slot index of [getChildren]: nil for an empty slot, a negative index, one past the end, or a dynamic widget (whose own children array…
getChildren(){ n: number, [number]: Widget? }?The widget's own children array, slot-indexed with holes; nil when it is empty. A component's holds every dynamic widget of it, those cre…
getDynamicChildren(){Widget}The dynamic widgets whose parent is this one, without holes: a component's own (those not created under a dynamic layer), or a dynamic laye…
setChildren({ n: number, [number]: Widget? }?)()Replaces the children array, for the arrays Bento can apply to the client's vector: nil drops it, and an array keeps, drops or pads what…
getStaticChildren(){Widget}The components whose parent is this one (none for a dynamic widget).
getNestedChildren(){Widget}The root components of the interface mounted on this component.
createChild(number, number)Widget(Widget, number, number) -> Widget: Creates a dynamic child of type in slot index (-1: after the last), as the client's CC_CREATE d…
createChild(number)Widget
deleteAllChildren()()Empties every slot of the widget's own children array, keeping its length: getChildren() then answers holes and createChild(-1, ...) st…
isHidden()booleanWhether the widget or any ancestor (through the mount of its interface) is hidden; a widget outside the top-level interface with no parent…
isSelfHidden()booleanWhether the widget's own hidden flag is set.
setHidden(boolean)WidgetSets the widget's own hidden flag.
getCanvasLocation()PointWhere the widget was last drawn on the canvas, as the client's draw loop records it ((-1, -1) before its first draw; a hidden widget keep…
getBounds()RectangleThe canvas area the widget covers: [getCanvasLocation] (the draw record once the layer points install, the layout before) and its laid-ou…
contains(Point)booleanWhether point is inside [getBounds] (the draw record's place once the layer points install, the layout's before).
getWidth()numberThe laid-out width.
setWidth(number)()Sets the laid-out width (the next revalidate() recomputes it from the original).
getHeight()numberThe laid-out height.
setHeight(number)()Sets the laid-out height.
getRelativeX()numberThe laid-out x, relative to the parent.
setRelativeX(number)()Sets the laid-out x.
getRelativeY()numberThe laid-out y, relative to the parent.
setRelativeY(number)()Sets the laid-out y.
getOriginalX()numberThe x before the position mode applies.
setOriginalX(number)WidgetSets the x the position mode applies to; revalidate() makes it take effect.
getOriginalY()numberThe y before the position mode applies.
setOriginalY(number)WidgetSets the y the position mode applies to.
getOriginalWidth()numberThe width before the width mode applies.
setOriginalWidth(number)WidgetSets the width the width mode applies to.
getOriginalHeight()numberThe height before the height mode applies.
setOriginalHeight(number)WidgetSets the height the height mode applies to.
setPos(number, number)Widget(Widget, number, number) -> Widget: Sets the original x and y.
setPos(number, number, number, number)Widget
setSize(number, number)Widget(Widget, number, number) -> Widget: Sets the original width and height.
setSize(number, number, number, number)Widget
getXPositionMode()numberThe x position mode (WidgetPositionMode).
setXPositionMode(number)WidgetSets the x position mode.
getYPositionMode()numberThe y position mode.
setYPositionMode(number)WidgetSets the y position mode.
getWidthMode()numberThe width mode (WidgetSizeMode).
setWidthMode(number)WidgetSets the width mode.
getHeightMode()numberThe height mode.
setHeightMode(number)WidgetSets the height mode.
revalidate()()Lays the widget out again against its parent (size, then position).
revalidateScroll()()revalidate(), then the children against the scroll size.
getScrollX()numberThe scroll x.
setScrollX(number)WidgetSets the scroll x.
getScrollY()numberThe scroll y.
setScrollY(number)WidgetSets the scroll y.
getScrollWidth()numberThe scrollable width.
setScrollWidth(number)WidgetSets the scrollable width.
getScrollHeight()numberThe scrollable height.
setScrollHeight(number)WidgetSets the scrollable height.
getText()stringThe text.
setText(string)WidgetSets the text.
getTextColor()numberThe text colour, RGB.
setTextColor(number)WidgetSets the text colour, RGB.
getFontId()numberThe font id.
getFont()FontTypeFace?The font the text is drawn in, nil when the font id is -1 or names no font of the game's font archive (as the client's: it loads none).
setFontId(number)WidgetSets the font id.
getTextShadowed()booleanWhether the text is drawn with a shadow.
setTextShadowed(boolean)WidgetSets whether the text is drawn with a shadow.
getLineHeight()numberThe line height.
setLineHeight(number)WidgetSets the line height.
getXTextAlignment()numberThe horizontal text alignment (WidgetTextAlignment).
setXTextAlignment(number)WidgetSets the horizontal text alignment.
getYTextAlignment()numberThe vertical text alignment.
setYTextAlignment(number)WidgetSets the vertical text alignment.
getName()stringThe name (the op base: what menu entries name the widget by).
setName(string)WidgetSets the name.
getTargetVerb()stringThe target verb (Use targets).
setTargetVerb(string)()Sets the target verb.
getOpacity()numberThe opacity, 0 (opaque) to 255.
setOpacity(number)WidgetSets the opacity.
getSpriteId()numberThe sprite id.
setSpriteId(number)WidgetSets the sprite id.
getSpriteTiling()booleanWhether the sprite tiles.
setSpriteTiling(boolean)WidgetSets whether the sprite tiles.
getBorderType()numberThe border type (the sprite outline thickness).
setBorderType(number)()Sets the border type.
isFilled()booleanWhether a rectangle is filled.
setFilled(boolean)WidgetSets whether a rectangle is filled.
getModelId()numberThe model id.
setModelId(number)WidgetSets the model id.
getModelType()numberThe model type (WidgetModelType).
setModelType(number)WidgetSets the model type.
getAnimationId()numberThe model's animation id.
setAnimationId(number)WidgetSets the model's animation id.
getRotationX()numberThe model's x rotation, 0..2047.
setRotationX(number)WidgetSets the model's x rotation.
getRotationY()numberThe model's y rotation, 0..2047.
setRotationY(number)WidgetSets the model's y rotation.
getRotationZ()numberThe model's z rotation, 0..2047.
setRotationZ(number)WidgetSets the model's z rotation.
getModelZoom()numberThe model zoom.
setModelZoom(number)WidgetSets the model zoom.
getItemId()numberThe item the widget shows, -1 for none.
setItemId(number)WidgetSets the item the widget shows.
getItemQuantity()numberThe item quantity.
setItemQuantity(number)WidgetSets the item quantity.
getItemQuantityMode()numberThe item quantity mode (when the quantity is drawn).
setItemQuantityMode(number)WidgetSets the item quantity mode.
getActions(){ n: number, [number]: string? }?The menu ops, nil for an unset one; nil when there are none. Holes are nil and the array carries n, its length: walk it `for i = 1,…
setAction(number, string?)()Sets menu op index, 0-based (the ops grow to hold it; nil empties it). Indices past 31 raise: the client's menu reads no more, and the…
clearActions()()Drops the menu ops: getActions() answers nil after. The sub-ops stay.
setSubOp(number, number, string?)()Sets sub-op subop of menu op index (both 0-based), growing the sub-op table to hold it; indices past 31 raise (the client's menu reads…
interact(string)booleanChoose option, one of the widget's menu ops ("Withdraw-1", "Close"; "" for its first), through the virtual mouse. The scheduler moves t…
interactOp(number, number?)booleanPress menu op op of the widget (1-based, a CC_OP identifier: action index + 1) through the virtual mouse, childIndex the menu entry's…
pressButton(MenuAction)booleanPress an if1 button of this widget: menuAction is MenuAction.WIDGET_TYPE_1 ("ok"), WIDGET_CLOSE, WIDGET_TYPE_4 (a toggle), `WIDGET_…
hasListener()booleanWhether the widget's listeners run.
setHasListener(boolean)WidgetSets whether the widget's listeners run (a listener setter does not).
getNoClickThrough()booleanWhether clicks pass through the widget to what is under it (false) or stop.
setNoClickThrough(boolean)()Sets whether clicks stop at the widget.
getNoScrollThrough()booleanWhether scrolling stops at the widget.
setNoScrollThrough(boolean)()Sets whether scrolling stops at the widget.
getDragDeadZone()numberThe drag dead zone, in pixels.
setDragDeadZone(number)()Sets the drag dead zone.
getDragDeadTime()numberThe drag dead time, in client cycles.
setDragDeadTime(number)()Sets the drag dead time.
getDragParent()Widget?The container the widget can be dragged in, when one is set.
getOnOpListener(){number | string}?The op listener: the script id, then its arguments; nil when unset.
getOnKeyListener(){number | string}?The key listener.
getOnLoadListener(){number | string}?The load listener (run when the interface loads).
getOnInvTransmitListener(){number | string}?The inventory-transmit listener.
getOnVarTransmitListener(){number | string}?The var-transmit listener.
getVarTransmitTrigger(){number}?The vars the var-transmit listener runs for, nil when it runs for any.
setOnOpListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the op listener: the script id then its arguments, a function first, or nothing (cleared). hasListener must be set for it to run. A…
setOnDialogAbortListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the dialog-abort listener.
setOnKeyListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the key listener.
setOnMouseOverListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the mouse-over listener.
setOnMouseRepeatListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the mouse-repeat listener.
setOnMouseLeaveListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the mouse-leave listener.
setOnTimerListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the timer listener (every client cycle).
setOnTargetEnterListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the target-enter listener.
setOnTargetLeaveListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the target-leave listener.
setOnClickListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the click listener (the first cycle the mouse is held on the widget).
setOnHoldListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the hold listener (every cycle but the first the mouse is held).
setOnReleaseListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the release listener.
setOnDragListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the drag listener.
setOnDragCompleteListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the drag-complete listener.
setOnScrollWheelListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the scroll-wheel listener.
setOnVarTransmitListener((((ScriptEvent) -> ()) | number)?, ...any)()Sets the var-transmit listener.

Returned by

MethodReturnsDescription
ChatboxPanelManager.getContainerWidgetWidget?The chatbox's message layer, which a panel builds its widgets in.
Client.getDraggedOnWidgetWidget?The widget under the dragged one that takes a drop (its config has WidgetConfig.DRAG_ON), as the client found it this cycle; nil when the…
Client.getDraggedWidgetWidget?The draggable widget a mouse press landed on (the client's clicked widget), from the press until the release, whether or not the drag has b…
Client.getFocusedInputFieldWidgetWidget?The widget whose input field has the keyboard focus (a field the game types into instead of the chatbox), or nil when none has it.
Client.getScriptActiveWidgetWidget?The widget the running script's cc_* instructions act on (the script VM's active component register: the component cc_find found or `cc…
Client.getSelectedWidgetWidget?The widget in target mode (the selected spell, or the inventory slot of a "Use" item); nil when none is, or it is gone.
Client.getWidgetWidget?(Client, number) -> Widget?: The widget with packed id id (group << 16 | child), or nil when its interface is not loaded. Raises when…
Client.getWidgetRoots{Widget}The top-level interface's root components.
MenuEntry.getWidgetWidget?The widget the entry acts on (a CC_OP, WIDGET_TARGET, WIDGET_CONTINUE, ...): client:getWidget(getParam1()), or its dynamic child `g…
MenuOptionClicked.getWidgetWidget?The widget the clicked entry acts on (getMenuEntry():getWidget()), or nil.
ScriptEvent.getSourceWidget?The widget the WIDGET_ID and WIDGET_INDEX sentinels name.
ScriptEvent.getTargetWidget?The drag-complete target, nil when there is none.
ScriptEventBuilder.getSourceWidget?The widget the WIDGET_ID and WIDGET_INDEX sentinels name.
ScriptEventBuilder.getTargetWidget?The drag-complete target.
WidgetItem.getWidgetWidget?The widget drawing it.
WidgetQuery.collect{ Widget }Every match, as handles. Consumes the query.
WidgetQuery.firstWidget?The first match, as a handle. Consumes the query.

Method details

getId

getId: (Widget) -> number

The packed component id, (group << 16) | component; a dynamic widget's is its component's.

getIndex

getIndex: (Widget) -> number

The slot in the component's children, -1 for a component.

getClickMask

getClickMask: (Widget) -> number

The click mask (WidgetConfig flags) the widget itself carries.

isIf3

isIf3: (Widget) -> boolean

Whether the widget is an IF3 (scripted) widget.

getParent

getParent: (Widget) -> Widget?

The parent widget, or nil (a root of the top-level interface, or an interface that is not open). A dynamic widget's parent is its component (client:getWidget(getParentId())).

getParentId

getParentId: (Widget) -> number

The parent's id: the widget's own parent component, else the component its interface is mounted on, else -1.

getChild

getChild: (Widget, number) -> Widget?

Slot index of [getChildren]: nil for an empty slot, a negative index, one past the end, or a dynamic widget (whose own children array is empty). Raises when index is not an int: nil, a fraction, NaN, inf or past int32.

getChildren

getChildren: (Widget) -> { n: number, [number]: Widget? }?

The widget's own children array, slot-indexed with holes; nil when it is empty. A component's holds every dynamic widget of it, those created under a dynamic layer included (they record the layer as their dynamic parent); a dynamic widget's is always empty (nil). A child's [getIndex] is its slot here.

getDynamicChildren

getDynamicChildren: (Widget) -> {Widget}

The dynamic widgets whose parent is this one, without holes: a component's own (those not created under a dynamic layer), or a dynamic layer's.

setChildren

setChildren: (Widget, { n: number, [number]: Widget? }?) -> ()

Replaces the children array, for the arrays Bento can apply to the client's vector: nil drops it, and an array keeps, drops or pads what the widget has (each entry the widget slot i holds now, or nil where it is empty). Any other array (one that moves or adopts a widget) raises. A static layer only.

createChild

createChild: ((Widget, number, number) -> Widget) & ((Widget, number) -> Widget)

(Widget, number, number) -> Widget: Creates a dynamic child of type in slot index (-1: after the last), as the client's CC_CREATE does; an occupied slot is replaced.

(Widget, number) -> Widget: Creates a dynamic child of type after the last.

deleteAllChildren

deleteAllChildren: (Widget) -> ()

Empties every slot of the widget's own children array, keeping its length: getChildren() then answers holes and createChild(-1, ...) starts at slot 0. A dynamic widget's own array is empty, so on one this changes nothing.

isHidden

isHidden: (Widget) -> boolean

Whether the widget or any ancestor (through the mount of its interface) is hidden; a widget outside the top-level interface with no parent is hidden.

getCanvasLocation

getCanvasLocation: (Widget) -> Point

Where the widget was last drawn on the canvas, as the client's draw loop records it ((-1, -1) before its first draw; a hidden widget keeps where it was drawn last): the draw record, once the overlay layer points install in the client; before them (a test VM, the host process), the place its layout gives, which is where a widget drawn this frame was drawn.

getBounds

getBounds: (Widget) -> Rectangle

The canvas area the widget covers: [getCanvasLocation] (the draw record once the layer points install, the layout before) and its laid-out size.

contains

contains: (Widget, Point) -> boolean

Whether point is inside [getBounds] (the draw record's place once the layer points install, the layout's before).

setWidth

setWidth: (Widget, number) -> ()

Sets the laid-out width (the next revalidate() recomputes it from the original).

setOriginalX

setOriginalX: (Widget, number) -> Widget

Sets the x the position mode applies to; revalidate() makes it take effect.

setPos

setPos: ((Widget, number, number) -> Widget) & ((Widget, number, number, number, number) -> Widget)

(Widget, number, number) -> Widget: Sets the original x and y.

(Widget, number, number, number, number) -> Widget: Sets the original x and y and their position modes.

setSize

setSize: ((Widget, number, number) -> Widget) & ((Widget, number, number, number, number) -> Widget)

(Widget, number, number) -> Widget: Sets the original width and height.

(Widget, number, number, number, number) -> Widget: Sets the original width and height and their size modes.

revalidate

revalidate: (Widget) -> ()

Lays the widget out again against its parent (size, then position).

getFont

getFont: (Widget) -> FontTypeFace?

The font the text is drawn in, nil when the font id is -1 or names no font of the game's font archive (as the client's: it loads none).

getName

getName: (Widget) -> string

The name (the op base: what menu entries name the widget by).

getItemId

getItemId: (Widget) -> number

The item the widget shows, -1 for none.

getActions

getActions: (Widget) -> { n: number, [number]: string? }?

The menu ops, nil for an unset one; nil when there are none. Holes are nil and the array carries n, its length: walk it for i = 1, ops.n. table.find stops at the first hole, so search it with your own contains(ops, x) that walks to n.

setAction

setAction: (Widget, number, string?) -> ()

Sets menu op index, 0-based (the ops grow to hold it; nil empties it). Indices past 31 raise: the client's menu reads no more, and the op table is the client's allocation.

clearActions

clearActions: (Widget) -> ()

Drops the menu ops: getActions() answers nil after. The sub-ops stay.

setSubOp

setSubOp: (Widget, number, number, string?) -> ()

Sets sub-op subop of menu op index (both 0-based), growing the sub-op table to hold it; indices past 31 raise (the client's menu reads no more).

interact

interact: (Widget, string) -> boolean

Choose option, one of the widget's menu ops ("Withdraw-1", "Close"; "" for its first), through the virtual mouse. The scheduler moves the virtual mouse onto the widget and clicks, and the menu entry it runs is that op of this widget (a dynamic child's index as its first param). false when the widget is gone, or it has no such op (getActions(), the text as the menu shows it).

interactOp

interactOp: (Widget, number, number?) -> boolean

Press menu op op of the widget (1-based, a CC_OP identifier: action index + 1) through the virtual mouse, childIndex the menu entry's first param (the widget's own index when omitted, -1 for a component). The scheduler moves the virtual mouse onto the widget and clicks, and the entry it runs is that op (CC_OP_LOW_PRIORITY past op 5, as the menu has it); the item id comes from the widget's own item. false when the widget is gone. Raises for an op outside 1..10. interact(option) names the op by its text instead.

pressButton

pressButton: (Widget, MenuAction) -> boolean

Press an if1 button of this widget: menuAction is MenuAction.WIDGET_TYPE_1 ("ok"), WIDGET_CLOSE, WIDGET_TYPE_4 (a toggle), WIDGET_TYPE_5 (a select) or WIDGET_CONTINUE, as the widget's menu entry names it (an old interface's button; interact(option) presses a CC_OP op, which every current interface uses). false when the widget is gone, or menuAction is another type.

getNoClickThrough

getNoClickThrough: (Widget) -> boolean

Whether clicks pass through the widget to what is under it (false) or stop.

getOnOpListener

getOnOpListener: (Widget) -> {number | string}?

The op listener: the script id, then its arguments; nil when unset.

getOnLoadListener

getOnLoadListener: (Widget) -> {number | string}?

The load listener (run when the interface loads).

getVarTransmitTrigger

getVarTransmitTrigger: (Widget) -> {number}?

The vars the var-transmit listener runs for, nil when it runs for any.

setOnOpListener

setOnOpListener: (Widget, (((ScriptEvent) -> ()) | number)?, ...any) -> ()

Sets the op listener: the script id then its arguments, a function first, or nothing (cleared). hasListener must be set for it to run. A function, here or in any setOn*Listener, is an error on a client whose table has the ScriptEvent_execute site off: nothing there would run it.