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.
You are correct, there is not a JSL message for getting the index of the selected menu item, like <<Get Menu Choice for ButtonBox. For this reason, you will need to pass the index of the menu item to whatever method you are using to change the menu item states.
Instead of using three different expressions, as you have above, I would recommend using a function with three parameters. Using a function removes the need for the extraneous variables and also simplifies the process for adding new menu items later on and reduces code duplication. See my example below for details.
Thanks Justin - I'll do that. I've discovered a few times in the past that I've overlooked a property which resolves the issue, just because I didn't appreciate its relevance to the problem in hand - so it's good to know that I haven't missed something obvious on this occasion.