20,741
edits
Line 88: | Line 88: | ||
var createButton = func(root, label, clickAction) { | var createButton = func(root, label, clickAction) { | ||
var button = canvas.gui.widgets.Button.new(root, canvas.style, {} ) | var button = canvas.gui.widgets.Button.new(root, canvas.style, {} ) | ||
.setText(label) | .setText(label) | ||
.setFixedSize(80, 32); | |||
button.listen("clicked", clickAction ); | button.listen("clicked", clickAction ); | ||
return button; | return button; | ||
} | } | ||
var (width,height) = ( | var (width,height) = (420,300); | ||
var title = 'DPS Keypad'; | var title = 'DPS Keypad'; | ||
Line 136: | Line 136: | ||
], | ], | ||
[ | |||
'MSG', | |||
'B', | |||
'E', | |||
'2', | |||
'5', | |||
'8', | |||
'0', | |||
'.', | |||
], | |||
[ | |||
'ACK', | |||
'C', | |||
'F', | |||
'3', | |||
'6', | |||
'9', | |||
'+', | |||
'PRO', | |||
], | |||
]; | ]; | ||
## button setup | ## button setup using 4 vertical boxes added to a single hbox | ||
foreach(var col; Buttons) { | foreach(var col; Buttons) { | ||
Line 147: | Line 168: | ||
foreach(var btn; col) { | foreach(var btn; col) { | ||
var button=createButton(root:root, label: btn, clickAction:func {print("button clicked:");}); | var button=createButton(root:root, label: btn, clickAction:func {print("button clicked:");}); | ||
# add the button to the vbox | # add the button to the vbox | ||
vbox.addItem(button); | vbox.addItem(button); | ||
} | } | ||
} | } | ||