Skip to main content
Version: v3

widget.setProperty(propertyId, val)

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Set the properties of the UI widget.

Type

(propertyId: string, val: any) => void

Parameters

ParameterDescriptionType
propertyIdThe property of ID.PropertyId
valSet the value. (when property is prop.MORE, val is used in the same way as createWidget's option, which can set multiple parameters.)any

PropertyId

List the properties commonly supported by the widgets.

PropertiesDescriptionType
xThe x-axis coordinate of the widget.number
yThe y-axis coordinate of the widget.number
wThe width of the widget.number
hThe height of the widget.number
VISIBLEWhether the widget is visible or not, true is visible, false is not, this property does not support setProperty(prop.MORE, {}), only setProperty sets the VISIBLE property aloneboolean
DATASETDeveloper-defined properties of the widget, obtained via widget.getProperty(prop.DATASET)any

Code example

import { createWidget, widget, prop, align } from '@zos/ui'

const button = createWidget(widget.BUTTON, Param)
button.setProperty(prop.VISIBLE, false)

const text = createWidget(widget.TEXT, Param)
text.setProperty(prop.MORE, {
x: 0,
y: 0,
w: 200,
h: 200,
text: 'hello',
color: 0x34e073,
align_h: align.LEFT
})

text.setProperty(prop.DATASET, {
name: 'text1'
})

const dataset = text.getProperty(prop.DATASET)