Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Right click context menu in texteditor

3 REPLIES 3
Reply
Message 1 of 4
marcin.sachs
269 Views, 3 Replies

Right click context menu in texteditor

Hi All,
I have a problem to add custom context menu item in texteditor. I've tried context menu extension but seems not work in this case. Do you have any ideas how to add item for context menu in text editor?

 

private static ContextMenuExtension menuExtension;
        internal static void Attach()
        {
            menuExtension = new ContextMenuExtension();
            MenuItem item = new MenuItem("Test");
            item.Click += new EventHandler(item_Click);
            menuExtension.MenuItems.Add(item);
            RXClass rxClass = Entity.GetClass(typeof(TextEditor));
            Application.AddObjectContextMenuExtension(rxClass, menuExtension);
        }

 

 

3 REPLIES 3
Message 2 of 4
norman.yuan
in reply to: marcin.sachs

If you paid attention to the first argument of the AddObjectContextMenuExtension() method, you would have known that there is no way for your code to work: TextEditor is NOT derived from RXObject class.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 4

ContextMenuExtension is primarily for adding items to the default right click menu in the drawing editor when there are objects selected.

 

It has no relation to the context menu for the in-place text editor, or any other context menus. As far as I know there is no API support for adding items to the in-place text editor context menus.

 

So, the only way to achieve your objective would be via WinAPI programming with some fairly-complicated code that involves subclassing windows and handling wm_contextmenu window messages.

Message 4 of 4

Maybe you can add something to the text editor ribbon

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report