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);
}
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
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.
Maybe you can add something to the text editor ribbon
Can't find what you're looking for? Ask the community or share your knowledge.