initializeUI() method. This is where you define the UI layout and elements.Pressable component from 'horizon/ui'. Place it inside the children array of a View.Pressable({
children: [
Text({
text: 'Press me',
style: { fontSize: 12 }
}),
],
// ...event handlers and style...
})Pressable elements to the children array. Each button can have its own text, style, and event handlers.style property and event handlers like onClick, onPress, onRelease, onEnter, and onExit.// OnClick Event Handler
onClick: () => {
console.log('Hello from the button!');
},
//Button Style
style: {
width: 120,
height: 50,
backgroundColor: 'green'
}
Binding instance to hold a value (e.g., button color or label).private buttonColorBinding = new Binding('gray');style: {
backgroundColor: this.buttonColorBinding,
} onPress: () => { this.buttonColorBinding.set('yellow'); },
onRelease: () => { this.buttonColorBinding.set('gray'); },
onEnter: () => { this.buttonColorBinding.set('white'); },
onExit: () => { this.buttonColorBinding.set('gray'); },
set(value, [player]) method.Pressable.onClick handler.