Hi @msk-k, actually I had some plans to register actions in different menu items (even items in the main menu bar but different locations, not only File > Extensions). I’ve found my incomplete patch.
Some notes about your changes:
- As in issue 1949, we have plans to register several things from extension scripts (commands, file formats, inks, etc.), so maybe
app.register()
is too much, or we should needapp.registerMenu()
or something likeapp.register{ menu="..." }
(my original API use names likeapp.newCommand
andapp.newMenu
). - There should be a way to unload a extension/script (remove all registered items)
- I would prefer other word for
"context"
(to avoid confusion with keyboard shortcuts “context”), but still not sure.
I think some design work is still needed for the exact API that we want for extension scripts. Something like this might be a possibility:
app.plugin{
load=function() ... end,
unload=function() ... end
}
Or other example:
function init() -- or load() or activate()
end
function exit() -- or unload() or deactivate()
end
Some ideas from VSCode.
Another good thing would be to have all registered items automatically unloaded:
function init(plugin)
plugin.register{ menu="edit.myMenu", ... }
end
So there is no need to create a exit()
function.