I'm very familiar with Custom Menus within FileMaker, but I'm not happy with them for a few reasons (the biggest: a layout automatically defaulting to a default menu is a nice feature but it should be able to be turned OFF.)
OnLayoutLoad Script Trigger to load a different menu?
Technically possible, yes - but not practical for us with the large number of layouts we have across our solutions. Thanks.
Personally I use [File Default] on the majority of my layouts and a specific custom menu for those that will always use the same custom menu.
If I then need to change the menu for the 'default' layouts, I do so using the following script step:
Install Menu Set ["menu to use" ; Use as file default ]
I think you answered your question... it means a lot of work updating layouts to script trigger the right menu.
But speaking of this... wouldn't it be nice to be able to write a script that created a script or modified a script or modified a layout's script triggers? In your case a looping script that would go through all layouts and add the script trigger you need to update the custom menu selection. Wouldn't it be nice to write a script that builds a whole database, schema, scripts and all. Or maybe do things to a layout. Boy the power scripting would have then and would solve problems like this. OH well, just dreaming!
The "Use as file default" suggestion really helps. Thanks.
Just a thought...
We used to have a large number of custom menu sets. We now have one. However, we get pretty detailed in our "install when" functions, so the one custom menu effectively changes from layout to layout, or for different privilege sets, but we only have one menu set to maintain (or install).
Another thought: we used to constantly "take down" the custom menu when doing development. We now include commands like "Replace" and "Delete found records" and "Manage Database" and so on in the one custom menu, with an install when that specifies that its only for full access users. Now we don't have to take down the menus while we're working.
These changes have made it so that having the custom menu as the "file default" isn't nearly the headache it used to be.
Managing the "install when" functions, like scripting an onRecordLoad, may seem like a lot of work, but having worked with menu plugins before, I consider that a much bigger headache.
I do the same a Chris Cain and have a single menu set and activate items as needed. You need some method for managing custom menus on a layout-by-layout basis though. I use textboxes on the layouts themselves.
I do a similar thing, ie a single, 'dynamic' custom menu that is the default. It also leaves out the various 'undesirable' commands, including 'Manage Database'. I've added a 'new' item - Developer View, with the keyboard shortcut that would normally apply to Manage Database. This item has a script which basically says, if it's the [Full Access] priv set, then load the standard FMP scripts instead.
Result: my menus always 'default' to the user's 'norm', but with a quick double keyboard shortcut, I can not only reload the menus but also get into Define Database (or whatever).
This is actually how we used to do it, with a menu item and keystroke for "developer menus" (really, standard menus).
However, hitting that keystroke a hundred times a day adds up, and besides that if we were on a client's machine without FMPA, we had to switch layouts and switch back to get the custom menus to load again.
By just including those "undesirable" commands with a hide when that says get ( accountprivilegesetname ) <> "[full access]", we no longer have to keep changing the menus, even as developers.
Now, if only keystrokes would ignore the custom menu in Manage Database, when I'm obviously full access and not trying to access custom menu items.
Makes sense. As in, I might switch to this strategy at some stage :-)
My reason (for now) for not doing so: I quite like the constant reminders that there's a custom menu to consider! (and I find those extra keystrokes very non-onerous).