Community
    • Login

    How to add a "Delete line" command to the context menu

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 2 Posters 848 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.
    • R JR
      R J
      last edited by

      Hi folks!

      I was following the instructions in the ContextMenu.xml file to add commands to the context menu, but that only seems to work for commands that already appear in the top menu, like “Duplicate current line” etc.

      That doesn’t seem to work for the scintilla command SCI_LINEDELETE (Ctrl+Shift+L). Is there a way to add that to the context menu?
      Or if there is another guide/help that can help with this, I’d appreciate a link…

      Thank you for your help!

      1 Reply Last reply Reply Quote 1
      • Alan KilbornA
        Alan Kilborn
        last edited by

        You could record+save a one-step macro for it.
        Give it a name e.g. “Line Delete”
        Then, in contextMenu.xml you could add such a line:

        <Item MenuEntryName="Macro" MenuItemName="Line Delete"/>
        

        There are probably other ways to achieve this as well.

        1 Reply Last reply Reply Quote 0
        • R JR
          R J
          last edited by

          Thanks for the quick response Alan!
          Sorry if this is a dumb question, but how do I give it a name? I tried typing in the Name box in the shortcut mapper but it’s not letting me change it there.

          2021-05-09_185955.png

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • Alan KilbornA
            Alan Kilborn @R J
            last edited by

            @R-J

            Sorry, didn’t realize you were so “noob”. :-)
            Forget Shortcut Mapper; nothing needed to do there.

            Use the Macro menu and start macro recording.
            Press Shift+Ctrl+L.
            Use the Macro menu to stop macro recording.
            Use the Macro menu to save your macro, thusly:

            e173539b-03b2-4389-a549-6db2a185b7c9-image.png

            After doing that your Macro menu will contain it:

            5424c6bd-be08-4205-9743-e5c5446c2814-image.png

            It is the appearing on the Macro menu that allows the contextMenu.xml entry that I showed before to work.

            1 Reply Last reply Reply Quote 2
            • R JR
              R J
              last edited by

              Yes i’m a complete noob, and thanks for taking the time to explain! So I created the macro like you showed me, but then I can’t seem to add that new command to the right-click context menu like you showed earlier.
              I tried adding this in contextMenu.xml:

              <Item MenuEntryName="Edit" MenuItemName="Line Delete"/>
              

              but it’s not showing up.

              Alan KilbornA R JR 2 Replies Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @R J
                last edited by

                @R-J said in How to add a "Delete line" command to the context menu:

                but it’s not showing up.

                Well, again maybe my original glossed over some details, when talking to a “noob”.
                You can’t just add it, like at the bottom.
                You have to insert it, at a valid place.
                Try inserting it around Copy or Paste since it is a similar function.

                Here’s where I did it (in yellow) and you can see it worked for me (circled in red):

                b87a2f1e-59f1-40f5-bc03-db06f80807bc-image.png

                1 Reply Last reply Reply Quote 2
                • R JR
                  R J
                  last edited by

                  Are you sure there isn’t an addition step I need to do for macros to appear in the context menu? As you can see, I added “Duplicate Current Line”, but the “Line Delete” isn’t showing up.

                  2021-05-09_203225.png

                  1 Reply Last reply Reply Quote 0
                  • R JR
                    R J
                    last edited by

                    OK I just noticed you used “Macro” for the MenuEntryName instead of “Edit”. This worked. I wish this was explained somewhere.
                    Thanks for your help!

                    Alan KilbornA 1 Reply Last reply Reply Quote 0
                    • R JR
                      R J @R J
                      last edited by

                      FYI the location doesn’t seem to matter, Alan. It works fine anywhere in the menu. Every place there seems valid.

                      1 Reply Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @R J
                        last edited by

                        @R-J said in How to add a "Delete line" command to the context menu:

                        I just noticed you used “Macro” for the MenuEntryName instead of “Edit”.

                        Well…yea, I mean, computers are picky about doing what you tell them.
                        I used “Macro” from the beginning.
                        And it makes sense, because we are trying to run something on the “Macro” menu (something we placed there).

                        I wish this was explained somewhere.

                        Well, it is.
                        See the user MANUAL for how to work with the context menu.
                        I mean, I guess I could have simply pointed you there in the beginning.

                        the location doesn’t seem to matter, Alan. It works fine anywhere in the menu. Every place there seems valid.

                        Well, yea…
                        But it has to be at a valid point in the XML structures.
                        You’ll remember that originally I just said “add it to contextMenu.xml”.
                        Well, a “noob” might open the file, scroll to the end, and paste it there.
                        That’s what I would do if someone told me that.
                        But that wouldn’t work for this file (it would be “off the end” of the proper structures).
                        The smarter thing, and what I intended, would be to observe what is there, and place anything new similarly – which is what I think you’re doing now.

                        Glad we finally got it worked out for you!

                        1 Reply Last reply Reply Quote 2
                        • R JR
                          R J
                          last edited by

                          Ah yes, that seems like a useful reference in the manual, and I always prefer to read documentation and learn on my own instead of asking on forms. I actually did a search in the manual for “context menu” before asking here, but it didn’t seem to find anything related at first glance. Now I realize that it only finds the titles of sections that may mention the keword, without highlighting any results.
                          So the search in the documentation isn’t great, especially for new users who don’t understand how it works and may think that it’s not finding their topic.

                          And what you said about the command location which has to be contained within a certain code structure, also makes perfect sense.

                          Thanks again.

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