• Login
Community
  • Login

Alternative to NPPM_REMOVESHORTCUTBYCMDID is required

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
3 Posts 2 Posters 1.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V
    Vitaliy Dovgan
    last edited by Nov 8, 2018, 12:54 PM

    I was thinking about this subject again and again, and here is my conclusion: the proposed approach with NPPM_REMOVESHORTCUTBYCMDID is a completely wrong direction.
    Here is why.
    The source of a problem is not in plugins, it’s in Notepad++ itself. Here is what I mean: the origin, the cause of the problem comes from the way how Notepad++ stores shortcuts for the plugins. Notepad++ maps the shortcut keys to the value of internalID that is not e.g. a unique hash of plugin’s menu item name, but something like a menu item’s position. Obviously, when this position is changed, the mappings between these positions and shortcuts becomes wrong.
    Now I’m asking a question: is it a plugin’s fault? What if Notepad++ stored some unique hash keys to identify plugin’s menu items disregarding the menu items’ positions, would we face this problem?
    And, by introducing NPPM_REMOVESHORTCUTBYCMDID , aren’t we in fact trying to fix Notepad++‘es internal issue in an external plugin’s code? Isn’t it strange?
    Moreover, anyway some different fix is needed to deal with moving (reordering) of menu items. Let me illustrate it by example. Let’s say we have the following scripts’ menu items created by NppExec with the following shortcuts assigned via the Shortcut Mapper:

    Script A - Shortcut A
    Script B - Shortcut B
    Script C - Shortcut C

    Now let’s assume we have reordered these items and added a new one by means of NppExec. This is how Notepad++ assigns the shortcuts to the reordered items:

    Script C - Shortcut A
    Script D (new one) - Shortcut B
    Script A - Shortcut C
    Script B - no shortcut

    This is completely wrong and has no chance to be fixed by NPPM_REMOVESHORTCUTBYCMDID, so another one additional “fix” is needed… or -

    So my proposal is to fix this issue in Notepad++ itself: do it once - and for all the existing and future plugins.

    1 Reply Last reply Reply Quote 1
    • D
      dinkumoil
      last edited by Nov 8, 2018, 1:59 PM

      A unique hash of the plugin’s menu item name wouldn’t work too. What if a user renames a script’s menu entry?

      1 Reply Last reply Reply Quote 0
      • V
        Vitaliy Dovgan
        last edited by Nov 9, 2018, 9:12 AM

        Yes, it’s one of possible problems. Though we can treat a renamed item as a combination of deletion and creation of a new item, so it’s OK for shortcut to disappear :)
        Another big problem with hashing menu items names will appear if a plugin supports different languages in its interface. In such case, different language will lead to completely different item names. Though, in case of menu items added by user it should not be a problem - since these items are added by user who fully controls the item names. But the problem with renaming of a menu item (after a shortcut has already been asdigned) still remanis.
        Maybe it would be worth to add some kind of Menu Items Manager to Notepad++'s plugin interface to deal with custom menu items created and modified by plugins.

        1 Reply Last reply Reply Quote 0
        1 out of 3
        • First post
          1/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors