Lets say I have a button that opens a popup menu with 2 levels:
Fruits> Apple
Banana
Melon
Vegetables> Carrot
Potato
Tomato
Is it possible to get both values? I mean, to receive information if fruits or vegetables was selected and also what kind of fruit/vegetable.
Thanks in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
You could use the cReturn property to encode a value that lets you determine both values, such as;
var choice = app.popUpMenuEx(
{cName: "Fruits",
oSubMenu: [ {cName: "Apple", cReturn: "Fruit,Apple" }, {cName: "Banana", cReturn: "Fruit,Banana" }, {cName: "Melon", cReturn: "Fruit,Melon" } ]},
{cName: "Vegetables",
oSubMenu: [ {cName: "Carrot", cReturn: "Vegetables,Carrot"}, {cName: "Potato", cReturn: "Vegetables,Potato"}, {cName: "Tomato", cReturn: "Vegetables,Tomato"} ]});
if (choice !== null)
{
var selection = choice.split(",");
app.alert("You selected the \"" + selection[1] + "\" menu item from the \"" + selection[0] + "\"");
}
Not ideal as you are effectively coding up the menu structure twice (and assumes you will never use a comma character in a menu item name).
Regards
Bruce
Views
Replies
Total Likes
Hi,
You could use the cReturn property to encode a value that lets you determine both values, such as;
var choice = app.popUpMenuEx(
{cName: "Fruits",
oSubMenu: [ {cName: "Apple", cReturn: "Fruit,Apple" }, {cName: "Banana", cReturn: "Fruit,Banana" }, {cName: "Melon", cReturn: "Fruit,Melon" } ]},
{cName: "Vegetables",
oSubMenu: [ {cName: "Carrot", cReturn: "Vegetables,Carrot"}, {cName: "Potato", cReturn: "Vegetables,Potato"}, {cName: "Tomato", cReturn: "Vegetables,Tomato"} ]});
if (choice !== null)
{
var selection = choice.split(",");
app.alert("You selected the \"" + selection[1] + "\" menu item from the \"" + selection[0] + "\"");
}
Not ideal as you are effectively coding up the menu structure twice (and assumes you will never use a comma character in a menu item name).
Regards
Bruce
Views
Replies
Total Likes
Thanks Bruce, just what I was looking for.
Views
Replies
Total Likes