Hi,
I have an outline box which has a menu script associated with it. That menu script has several menu items, some of which have submenus. Many of the submenus contain a set of mutually exclusive options that I want to place a tick by when they are selected, while at the same time unchecking all the alternatives (so for example, if my submenu sets the number of decimal places in a table to 1, 2, 3 or 4, then if I select "2", I will want to check the "2" item, and uncheck the "1", "3" and "4" items).
I'm still developing this application, so the actual menu structure is constantly changing as I add new options and/or modify existing ones. I therefore want to avoid having to hard-code the above checking/unchecking process. Instead, I want to automatically identify within which submenu I've just clicked on an item, and then just run a little function that clears all the ticks within the same submenu, and then checks the item I've just clicked. I can do this with the help of the "<< get submenu" property if I can get my script to tell me which menu item I've just clicked on.
I could set up a counting variable for each item (i.e. "M=1" for the first menu item, "M=2" for the second, "M=3" for the third and so on) and then just refer to the value of M to work out which item I've just clicked (as I've done in the little example below which I've cooked up just to illustrate the problem), but I would then have to change all the assignments every time the menu was edited - which rather defeats the object of the exercise.
Can this be done? I can't see any property of an outline box that would supply me with this information.
Many thanks
expr_POD = expr(for(i=1, i<=4, i++, My_OutlineBox << set menu item state(1+i, 0)); My_OutlineBox << set menu item state(1+POD, 1));
expr_Rec = expr(for(i=1, i<=3, i++, My_OutlineBox << set menu item state(6+i, 0)); My_OutlineBox << set menu item state(6+Rec, 1));
expr_Doc = expr(for(i=1, i<=4, i++, My_OutlineBox << set menu item state(10+i, 0)); My_OutlineBox << set menu item state(10+Doc, 1));
My_OutlineBox = OutlineBox("My OutlineBox",
textbox("Some stuff in the window"),
<< set menu script(
{
"Decimals", " ",
"1 POD", POD=1; expr_POD,
"2 POD", POD=2; expr_POD,
"3 POD", POD=3; expr_POD,
"4 POD", POD=4; expr_POD,
"Recipient", " ",
"R and D", Rec=1; expr_Rec,
"Marketing", Rec=2; expr_Rec,
"Pre-Sales", Rec=3; expr_Rec,
"Document Format", " ",
"Quarto", Doc=1; expr_Doc,
"Foolscap", Doc=2; expr_Doc,
"A4", Doc=3; expr_Doc,
"Tablet", Doc=4; expr_Doc,
"Email", Doc=5; expr_Doc
}
),
/* Define submenus */
<< set submenu( 1, 4),
<< set submenu( 6, 3),
<< set submenu(10, 5),
/* Set defaults */
<< set menu item state(2, 1),
<< set menu item state(7, 1),
<< set menu item state(11, 1)
);
new window("NW",
My_OutlineBox
);