Re: Cannot identify the Menubar button clicked under Mac OS
On 2/25/20 10:48 AM, Richard Gaskin via use-livecode wrote: Are the Lessons also at Github? Would be nice if someone here has a moment to update that. Lessons unfortunately are not on github. They're editable only through ScreenSteps, which doesn't have a linux option. I can no longer even reply when comments are posted. -- Mark Wieder ahsoftw...@gmail.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Cannot identify the Menubar button clicked under Mac OS
Tore Nilsen wrote: > 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. Agreed: the engine behavior is fine, the Lesson script is written in a way I've never seen anyone attempt, and will fail. Are the Lessons also at Github? Would be nice if someone here has a moment to update that. We should also consider adding a menu update example in the User Guide. Most of the Guide's discussion in "Programming Menus and Menu Bars" is pretty good, and there's even a useful example of handling menuPick, but no example for updating via mouseDown. > 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. Definitely not a bug, at least as far as original intent. Dr. Raney was quite clear when I discussed this with him some 20 years ago that he had no intention of jumping through the hoops that would be needed to try to treat the OS menu bar as a collection of LiveCode buttons. A quick change to that one Lesson resolves the issue; extra bonus points if we add that to the User Guide as well. Yes, if only everything else was this easy. I'd love to submit a pull request to a Lesson to make it possible to play video on Linux from within LC. :) -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Cannot identify the Menubar button clicked under Mac OS
> 25. feb. 2020 kl. 17:57 skrev Richard Gaskin via use-livecode > : > >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. Best regards Tore Nilsen ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Cannot identify the Menubar button clicked under Mac OS
Henry Lowe wrote: > The Livecode Lesson 'Update a menu with a list of open windows' > recommends placing a mousedown handler in the script of the Menubar > group to determine which menu was clicked on: > > http://lessons.livecode.com/m/2592/l/126566-update-a-menu-with-a-list-of-open-windows > > The suggested code is: > > on mouseDown >if the short name of the target is "Window" then > > However under Mac OS, using LC 9.6.0 (dp2), 'the short name of the > target' actually returns the name of the Menubar group not the menu > that was clicked. This appears to be a longstanding bug, first > reported in 2007: > > https://quality.livecode.com/show_bug.cgi?id=5142 > > Anyone know of a workaround for this? No workaround needed: use the group's mouseDown message to update your menus, for the reasons Curry described. Mac menus are already an exception in a great many respects. On Windows and Linux they are buttons, but on Mac the buttons are merely placeholders for properties used to recreate them dynamically as a native macOS menubar. They also change stack size. Only one menubar is visible at a time, giving rise to the Mac-specific defaultMenubar. There are probably other differences. As the only OS with a global menu bar, it is by its nature an exception; we can expect exceptional methods to work with it. But update handling isn't one of the exceptions here, if we consider the nuances of the interaction: If we attempt to update a single menu on mouseDown, what happens when the user clicks down on any menu other than the Windows menu, then slides over to the Windows menu? In normal LC messaging behavior, no mouseDown message would be sent to the Windows menu button. To attempt to update a single menu would require you to track mouseDown messages across all menu buttons in the group, and track mouseEnter messages to then explicitly send an update message to the one the mouse is over. This would be tedious for us to script, and a heckuva lotta work for the engine team to coerce those messages from the mouse position within the macOS menu bar. When it comes up updating menu contents, because of sliding-while-down, that's an action you'd want to do for all menus whenever any of them is clicked on, on all platforms. So just put the update routines in the group and you're good. The messaging mechanics are described in the tutorial you linked to: 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. It's been this way since MetaCard was first ported to MacOS, and while it does add to the long list of ways menus behave differently with macOS' native global menubar, it handles the use case well, better than attempting to handle this in the button itself. I've added a note in the bug report suggesting we add something in the Dictionary entry for menubar to note the messaging exception and that content updates are best handled with-the-grain on that. -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Cannot identify the Menubar button clicked under Mac OS
Henry: > Anyone know of a workaround for this? Just be aware that many LC "lessons" are flawed. Don't believe everything you read. Beyond the bug, updating Windows menu only on its own mousedown is already a failing strategy to begin with (bad instruction from "lesson") because the user can browse ALL menus after a single click. Therefore for your purpose, you DON'T need to know which menu was clicked. Just update them all. (But the bug should be fixed anyway - target should always work.) Best wishes, Curry Kenworthy Custom Software Development "Better Methods, Better Results" LiveCode Training and Consulting http://livecodeconsulting.com/ ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode