Skip to main content
Version: v3

widget.setProperty(propertyId, val)

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 hmUI.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 components.

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

Code example

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

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