Shortcuts in the Menus

Developers
2005-02-03
2013-04-26
  • (From the feature request:)

    The drscript labels are now automatically added (this was easy).

    Plugins are more tricky.  You need to load the plugin to find out what the shortcut functions are, and you need to load the shortcuts first to use them in the plugin!

    The solution is a bit odd.

    I set things up so the shortcuts are partially loaded before the plugin (if they exist), then the plugin, then the shortcuts finish loading.

    In the plugin itself, what you need to do is:

    move the AddPluginFunction *before* appending an item to the the menu, and you will be able to retrieve the shortcut for use in the label.

    You can still do it the old way anyway, but you will not have the shortcuts added.

     
    • Thanks, I'm looking forward to use it.

       
    • Apologies, but this has been taken out.

      It turns out this is trickier than I thought (for plugins, the drscript stuff is still in there).

      Here is the problem:

      If I do not load part of the shortcuts before the actual plugin, then you cannot grab the shortcut text.

      Making a function to just grab the text out of the file would mean reading the shortcuts file twice for each plugin!

      If I do load the shortcuts partly before, and after, they get so out of sync the shortcuts no longer function properly.

      So.

      I've decided to leave this out for now, and focus on
      the encoding (which I basically have working).

      I am still not quite sure of how to handle this.

      What may have to happen, is that the plugin
      may have to load shortcuts explicitly.  (or perhaps an option to explicitly load shortcuts, which, if activated, will cause drpy to skip loading them after the plugin?)

      If this is the case, then you could then:

      DrFrame.AddPluginFunction

      DrFrame.LoadPluginShortcuts()

      Then do the menu.

      I figured all of this can wait until I figure out the critical bug (encoding).

      Plus, I'd like to think about it some more, and get a few more opinions.

       
    • I think I figured out a way to do this fgr plugins.

      DrFrame.LoadPluginShortcuts(plugin)

      This can only be called once.

      So if you call it from the plugin as such:

      DrFrame.LoadPluginShortcuts('Tester')

      DrFrame.AddPluginFunction('Tester', 'Test', OnTest)

      DrFrame.programmenu.Append(ID_TEST, DrFrame.GetPluginMenuLabel('Tester', 'Test'))

      Everything should work (in theory, I haven't implemented this yet).

      Then, when drpy finished initializing the plugin itself,
      it can call .LoadPluginShortcuts for the plugin.

      The function itself can check to see if that plugin has already been loaded into shortcuts, and if so,
      simply return without doing anything.

       
    • Turns out this works (and will be in the next release).