How to prevent SyntaxEditor handling context menu

SyntaxEditor for WPF Forum

Posted 13 years ago by James Deadman
Version: 11.1.0542
Avatar
Hello,

Can i please ask about Syntax Editor handling context menu clicks. I noticed some other threads about this but without an answer to this particular question.

We need to prevent Syntax Editor from handling and displaying the context menu when the user right-clicks. The reason is that our application uses a third party tool which takes over a given control's context menu event and displays its own context menu instead. However currently because Syntax Editor handles it first, the context menu of Syntax Editor is displayed instead and the 3rd party tool doesnt receive it.

Eseentially we need to prevent Syntax Editor from setting the 'handled' flag and from displaying a context menu. How would i do this please?

(Please note that we currently do not derive from Syntax Editor, but just uses and interacts with it as a seperate control).

Thanks,
James

Comments (4)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi James,

In the current official build 543, you can set the attached ContextMenuService.IsEnabled property to false (which may also affect the third party menu) or can override SyntaxEditor.OnContextMenuOpening and not call the base method.

In the next build (not yet released at the time of this posting), we already have code in that adds a protected virtual CreateDefaultContextMenu that you could override to return null from, as a third option.

Do you think it would be beneficial to add another dependency property for whether the default context menu functionality is enabled at all?


Actipro Software Support

Posted 13 years ago by James Deadman
Avatar
Hi,

Thanks for your reply and help.

Firslty I will attempt to set the property to disabled as you suggest and see if that does the trick. I have downloaded the latest build 543, but i cannot seem to locate the 'ContextMenuService.IsEnabled' property (i checked the designer properties and also tried finding it with intellisense). How can i access the ContextMenuService.IsEnabled property to disable it please?

I guess it might be useful to add the additional dependency property for disabling the default context menu. (especially so if i'm unable to prevent the default one from being overriden :-).

Thanks,
James
Posted 13 years ago by James Deadman
Avatar
Hi,

No problem i have found how to set the flag programmicatically (i'm not so familiar with WPF!).

In case its useful to other developers, i set it using the following statement:

System.Windows.Controls.ContextMenuService.SetIsEnabled(mySyntaxEditor, false);

This seems to prevent the Syntax Editor context menu from appearing, and also enables the 3rd party tool to display their context menu as we hoped. :-)

Thanks for your help.
James
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi James,

Glad that worked. We're going to add a SyntaxEditor.IsDefaultContextMenuEnabled property for the next build anyhow.


Actipro Software Support

The latest build of this product (v24.1.2) was released 0 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.