Community
    • Login

    Question: What code to use TextFX tools in pop-up context menu?

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    5 Posts 3 Posters 3.5k 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.
    • Amanda GrahamA
      Amanda Graham
      last edited by

      I have customized the pop-up context menu to help me use certain text-wrangling tools. I would like to include some of the TextFX tools, but I can’t make them appear on the list. The instructions are “To add plugin commands, you have to use PluginEntryName and PluginCommandItemName to localize the plugin commands.” I can see that it works for the Base64 Encode, as that’s a default option on the context menu.

      I can’t make the Spell Checker plugin show up on the list, nor any of the TextFX tools either.

      What am I doing wrong? These are the entries I’ve inserted into contextMenu.xml that fail to appear:

      <Item FolderName=“Plugin commands” PluginEntryName=“Spell-Checker” PluginCommandItemName=“Spell-Checker”/>
      <Item FolderName=“TextFX” PluginEntryName=“TextFX Edit” PluginCommandItemName=“Kill unquoted (VB) whitespace” ItemNameAs=“Remove spaces”/>

      Thanks.

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner @Amanda Graham
        last edited by

        @Amanda-Graham

        TextFX is not a “typical” plugin. For some reason, it thinks it is different enough NOT to be installed under the Plugins menu, and creates a top-level “TextFX” menu for itself (not sure where this narcissistic attitude came from). This might be the root of the trouble you are having. I believe the “plugin” command structure for the context menu is definitely looking in the Plugins menu tree to find what it is looking for, and since TextFX isn’t there…

        When I tried configuring it for the context-menu like a normal Notepad++ menu item (e.g. modeling it after the “Block comment” context menu item–because that is nested in a submenu–like the TextFX items), I didn’t have any luck getting it running that way. Not sure why, it seems like that should have worked…

        Amanda GrahamA 1 Reply Last reply Reply Quote 1
        • Amanda GrahamA
          Amanda Graham @Scott Sumner
          last edited by

          @Scott-Sumner Thanks for the reply.

          I thought maybe I needed to specify MenuEntryName=“TextFX”, but that doesn’t make it work either.

          Sigh.

          1 Reply Last reply Reply Quote 0
          • dinkumoilD
            dinkumoil
            last edited by dinkumoil

            @Amanda-Graham

            As @Scott-Sumner already stated: TextFX is different. Therefor it behaves different when it comes to including its tools into the context popup menu. There are two methods to find out the codes you have to write to the file “contextMenu.xml”.

            1. If you open the shortcut mapper dialog and switch to the “Plugin commands” tab you will find some entries that start with an uppercase letter followed by a colon.

            2. When you click on menu “Settings” -> “Edit Popup ContextMenu” Notepad++ loads the file “%UserProfile%\AppData\Roaming\Notepad++\contextMenu.xml”. If you look into the TextFX menu now, you will notice that all menu entries (except the ones in the “TextFX Characters” submenu) are preceded by uppercase letters followed by a colon.

            To put entries in the popup context menu you have to create XML nodes in “contextMenu.xml” which contain exactly the same text as the shortcut mapper/menu entries including the preceding uppercase letter and the colon.

            1. If you want to add a TextFX tool from the “TextFX Characters” submenu to the main level of the context popup menu you have to add a child node like the following to the “ScintillaContextMenu” XML node:

               <Item PluginEntryName="TextFX Characters" PluginCommandItemName="Sentence case." />
              
            2. If you want to add a TextFX tool to the main level of the context popup menu whose shortcut mapper/menu entry is preceded by an uppercase letter and a colon you have to add a child node like the following to the “ScintillaContextMenu” XML node:

               <Item PluginEntryName="TextFX Characters" PluginCommandItemName="Q:Duplicate Line or Block" ItemNameAs="Zeile/Markierung duplizieren" />
              

              The “ItemNameAs” attribute can be used to localize an entry.

            3. If you want to add a TextFX tool to a submenu of the context popup menu called “Plugin Befehle” you have to add a child node like the following to the “ScintillaContextMenu” XML node:

               <Item FolderName="Plugin Befehle" PluginEntryName="TextFX Characters" PluginCommandItemName="Q:Duplicate Line or Block" ItemNameAs="Zeile/Markierung duplizieren" />
              

            Please note that the value of the attribute “PluginEntryName” always has to be “TextFX Characters” regardless of the title of the originating submenu.

            Amanda GrahamA 1 Reply Last reply Reply Quote 3
            • Amanda GrahamA
              Amanda Graham @dinkumoil
              last edited by Amanda Graham

              @dinkumoil All I can say is, thank you. I am very happy. I didn’t know to keep the the value of the attribute “PluginEntryName” as “TextFX Characters”.

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