I’m trying to customize the mainmenu in a notebook-based application
So far I’ve been able to remove quite a few of the menu entries, but am failing with a few remaining ones
For these entries in the menu that I can’t seem to disable, the command names that I find in the code don’t seem to trigger, for example these
so I was wondering if there’d be a simple way to kind of dump the mainmenu with the commands actually used in there so I’d stop trying to blindly guess the command names that I need to use…
If entries are added programatically rather than by schema these cannot be be disabled via schema I think (the cusomization via schema is rather recent so some places/extensions were not yet migrated, and in a few places it does not makes much sense to migrate). But the dump of all menu command is JSON Settings Editor if this helps:
It could be that there was a reason for not moving some settings out, but I think that in this case it could have been an omission (possibly worth checking by opening an issue first/asking on gitter - if not one replies quickly go for a PR).
iiuc you’re saying that I can’t use settings to disable entries created through the API; but could I use the API to cancel them then ? honestly in my case if I could use something like mainMenu.removeAllEntriesInCategory("terminal"), I’m making it up but I mean something that filters out all commands that start with terminal:, when then my life would be so much easier (or similar operations to cancel one specific command, or based or a regexp, etc…)
well, that is what I had in mind by saing “private attributes of IMainMenu” because while lumino Menu does allow to acess/remove specific items, the public API of IMainMenu does not expose these methods (you can still use them - which requires a bit of poking to find out how - but it is not officially supported and might break in the future)
worth being outlined maybe, for others who would run into this, without the "args": { "isMenu": true} thing, the menu remains; it came as a surprise because (1) it seemed more natural to disable based on the command only, and (2) what does it mean for these entries to be tagged as "args": { "isMenu": true} in the first place ?
in any case, thanks a million @krassowski as usual for your helpful insights
I think it does argument (args) comparison because a single command can be used in the menu multiple times. For example imagine a command zoom which has
{
label: (args) => `Zoom x${args.factor} times`
}
it could be used with args: {factor: 1.5} and args: {factor: 2} resultin to two menu items with labels Zoom x1.5 times and Zoom x2 times.
A PR adding a clarification to the docs would certainly be welcome.