Skip to main content

Component (컴포넌트) Widget Control

Widget Control (Property · Method · Event) you use to control the Component widget from a script. To learn what the widget does and how to use it, visit the Component doc.

info

The componentID in the examples below is the name (ID) you assigned to the Component widget on the canvas. In a script, access it as widgetID.member.

Widget Control summary

Widget ControlKindSignatureDescription
getVarMethodcomponentID.getVar(name)Reads the value of a variable the Component exposes
setVarMethodcomponentID.setVar(name, value)Changes the value of a readwrite variable
onVarChangedEventcomponentID.onVarChanged = (name, value, prev) => { ... }Runs when an exposed variable changes

Property

info

Not applicable — the Component widget has no script-only Property. In a script, read and write values with the common Widget Control below (getProperty / setProperty).

Method

getVar

Reads the current value of a variable the Component exposes (readable · readwrite). Returns null when the name doesn't exist or the variable is private.

  • Kind: Method
  • Parameters: name (string) — the name of the variable to read
  • Returns: The variable value (any type). null if the variable is unknown or private

Example

const checked = componentID.getVar("checked");

setVar

Changes the value of a readwrite variable on the Component. Does nothing if the variable is unknown, private, or read-only (readable).

  • Kind: Method
  • Parameters: name (string) — the variable name / value (any type) — the new value
  • Returns: None

Example

componentID.setVar("checked", true);

Event

onVarChanged

Runs whenever any variable the Component exposes changes value. The handler receives the changed variable name, the new value, and the previous value as arguments.

  • Kind: Event
  • Handler arguments: name (variable name) / value (new value) / prev (previous value)
  • Returns: None

Example

componentID.onVarChanged = (name, value, prev) => {
if (name === "checked") {
// Code to run on change
}
};

Common Widget Control (all widgets)

note

Every widget supports name-based common Widget Control (Method) such as setProperty / getProperty / setStyleProperty. See the common reference doc (to be written).