-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRadioButtons.mjs
36 lines (33 loc) · 1.46 KB
/
RadioButtons.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Radio button group example
*/
var RadioButtonsAction = {};
RadioButtonsAction.testPromptAction = tiled.registerAction("RadioButtons", function (action) {
var dialog = new Dialog();
dialog.addHeading(
`Choose the fruit`, true);
var radioGroup = dialog.addRadioButtonGroup("Your fruit:", ["Lemon", "Apple", "Pear"], 'Your favorite fruit selection.',
['Lemon: A sour, yellow fruit.', 'Apple: Many varieties varying in sweetness and tartness.', 'Pear:Uniquely shaped fruit.']);
radioGroup.addItem('Strawberry', 'Red, seed-filled, delicious fruit');
radioGroup.idToggled.connect(function (id, checked) {
if (!checked) {
return;
}
tiled.log(`Something was clicked. ID: ${id}. Checked: ${checked} Checked button: ${radioGroup.checkedButton.text}`);
tiled.log(`Checked index: ${radioGroup.checkedIndex}`)
})
tiled.log(`Buttons: ${radioGroup.buttons}`)
tiled.log(`First button: ${radioGroup.buttons[0].text}`)
// radioGroup.buttons[0].checked = true;
tiled.log(`Checked index with nothing checked: ${radioGroup.checkedIndex}`)
var forceAppleButton = dialog.addButton('Force apple selection');
forceAppleButton.clicked.connect(function(){
radioGroup.buttons[1].checked = true;
})
dialog.show();
});
RadioButtonsAction.testPromptAction.text = "Radio Buttons";
tiled.extendMenu("Edit", [
{ action: "RadioButtons", before: "SelectAll" },
{ separator: true }
]);