How to add or build my custom context menu?

SyntaxEditor for WPF Forum

Posted 12 years ago by Nassim Farhat
Version: 11.2.0551
Avatar
Hello,

Back with the old syntax editor, we used to be able to alter the context menu to whatever we wanted by hooking up to the editor's ContextMenuRequested event as such:

private void OnContextMenuRequested(object sender, ContextMenuRequestEventArgs e)
{
...
ContextMenu menu = this.STsyntaxEditor.GetDefaultContextMenu();
...
...
//build the context menu and show it
...
this.STsyntaxEditor.DefaultContextMenuEnabled = false;
}
The events do not seem to be the same with the WPF editor.

I tried to hookup to the editor's event:
OnContextMenuOpening()
but it never fired unless i clicked on the scroll bars or the editor margin, but on the editor itself the event was not triggered.

How do i accomplish this in SyntaxEditor WPF?

Thank you
Nassim

[Modified at 01/06/2012 04:26 PM]

[Modified at 01/09/2012 09:33 AM]

Comments (2)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Nassim,

We show our default context menu in a SyntaxEditor.OnContextMenuOpening override if e.Handled is still false and SyntaxEditor.IsDefaultContextMenuEnabled is false. Our override of that method calls base.OnContextMenuOpening(e); before we start our logic so the event should fire if WPF would normally fire it.

If you aren't getting a ContextMenuOpening event, then perhaps try inheriting SyntaxEditor and overriding the OnContextMenuOpening method like we do.


Actipro Software Support

Posted 12 years ago by Nassim Farhat
Avatar
thank you... i inherited and it all went fine :)
The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.