(1) This wording isn't clear about whether the change they're talking about happens manually through a mouse action or through a script. I discovered on my own that menuHistory is actually set automatically when choosing with the mouse, but the User Guide doesn't mention that at all. This should be clarified.If you change the currently-chosen menu item in option menus, also set the button's menuHistory property to the line number of the newly chosen item. This ensures that the new choice will be the one under the mouse pointer the next time the user clicks the menu.
(2) The UG says that the menuHistory determines what will be under the mouse pointer the next time the user clicks the menu. Not in my experience. Either the doc or the program should be changed so they agree.
(3) Getting something as simple as the selected menu item to be displayed and checked, and the previously selected item to be unchecked, takes a ridiculous amount of code (unless I'm missing something). This behavior is so basic I'd expect it to be built-in (which is my feauter request). This could be done with properties like "setLabelToSelection" and "setSingleCheckmarks". Here's the code I finally got working to do this for a popup menu. And in order for this to work, every menu item has to start with "!n".
Code: Select all
on menuPick theMenuItem
put the menuHistory of me into currentLine
global lastCheckedLine
if lastCheckedLine is empty then put 1 into lastCheckedLine
put line lastCheckedLine of me into lastCheckedText
put "!n" & char 3 to the number of chars of lastCheckedText of lastCheckedText into line lastCheckedLine of me
put currentLine into lastCheckedLine
put "!c" & theMenuItem into line currentLine of me
set the label of me to theMenuItem
end menuPick