Nevron Forum

NContextMenu problem with NRichTextBox

https://www.nevron.com/Forum/Topic5937.aspx

By Brian J Warren - Thursday, December 8, 2011

Hello Nevron,

I have a small problem using an NContextMenu with an NRichTextBox.  The attachment named CorrectMenu.jpg shows the correct NContextMenu displayed when clicking the NRichTextBox underneath.  This is implemented by displaying the NContextMenu on the MouseDown event of the NRichTextBox (checked for a right-click).  This only works properly when the NRichTextBox does not have focus.

The problem happens when the NRichTextBox does have focus (and displays the flashing cursor).  When the user does a right-click, the proper menu comes up, but then immeadiatly after the NRichTextBox default menu comes up and covers it (see attachment named DefaultMenu.jpg). 

Can you tell me the correct way to make this work?

Thank you, Brian Warren

By Nevron Support - Thursday, December 8, 2011

Hello Brian,

This is happening because NRichTextBox has build in Context menu, and when the control is focused and you right click on it it shows both.
Currently, you can disable this context menu by overriding WndProc as follows:

public class MyNRichTextBox : NRichTextBox
{
   protected override void WndProc(ref Message m)
   {
      if (m.Msg != Nevron.Interop.Win32.NWMConstants.WM_RBUTTONUP)
      {
         base.WndProc(ref m);
      }         
   }
}

In the next release we will add a new property which turns it on and off.
By Brian J Warren - Friday, December 9, 2011

Thank you to the Support Team,

That worked fine.  Thank you for the help.

Best regards, Brian Warren