Howto:Creating a Canvas GUI dialog file: Difference between revisions

Jump to navigation Jump to search
m
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(150, 32);
         .setFixedSize(80, 32);
button.listen("clicked", clickAction );
button.listen("clicked", clickAction );
return button;
return button;
}
}


var (width,height) = (240,480);
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) {
print("Setting up button:", btn);
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);
}
}
}  
}  


Navigation menu