Cannot identify the Menubar button clicked under Mac OS
tore.nilsen at me.com
Tue Feb 25 13:08:51 EST 2020
> 25. feb. 2020 kl. 17:57 skrev Richard Gaskin via use-livecode <use-livecode at lists.runrev.com>:
> Cross-platform note: When a menu button is being displayed in
> the Mac OS menu bar, it does not receive mouseDown messages,
> but its group does. For this reason, this example handler
> should be placed in the script of the menu bar group, rather
> than in the menu button. The first line of the handler makes
> sure it's only executed if the user clicked the Window menu.
> This ensures that the example will work on all platforms.
The problem here is that when a group is set to behave as a menubar on MacOS, the target becomes the group and not any of the individual buttons. Therefore the script as it is written in the tutorial will not work, since the update of the menu will only happen if the short name of the target is «window». It will work if you remove the encapsulating if-statement.
Removing the if-statement will update the content of the «Window» menu regardless of which menu you choose, provided that the script is placed in the group script. This way the user may well choose another menu initially, slide to the «Window» menu and be presented with an updated menu. So, while this may be a bug, the way around it is to write less code. If only all problems could be solved this way.
More information about the use-livecode