The focus events for the RadRichTextBox don't appear to be firing correctly. There's a number of issues, which I'll list in turn. We need to do things according to whether the control has the focus or not, and currently its unexpected behaviour is causing us a lot of problems.
For the purpose of reproducing the behaviour, simply place a RadRichTextBox control on a view, and handle its GotFocus and LostFocus events with the following event handlers, which will write to Visual Studio's Output window so you can see that they've been called.
private void RadRichTextBoxEx_LostFocus(object sender, RoutedEventArgs e)
private void RadRichTextBoxEx_GotFocus(object sender, RoutedEventArgs e)
#1 - Clicking the mouse anywhere within the control fires the events
Let's say the RadRichTextbox control has the focus. Clicking the mouse anywhere within the control fires the LostFocus and GotFocus events twice, with the following output in the VS Output window:
I would expect neither the LostFocus not the GotFocus events to be fired, as the control already has the focus.
If the control doesn't have the focus and you click in it (giving it the focus), then the following events are currently raised:
In this situation, I would expect only the first GotFocus event to be raised.
NOTE: I have tried handling the KeyboardGotFocus/KeyboardLostFocus events, and they behave the same way.
#2 - Clicking on a control that doesn't take focus, still fires these events
Let's say the RadRichTextBox control has the focus, and you click on a different control that doesn't steal the focus from the RadRichTextBox control, such as a ribbon button (note, we aren't using the Telerik ribbon currently, but that shouldn't matter). Doing so fires the events like so:
The expected behaviour is that neither of those events should be called.
#3 - When overriding the RadRichTextBox control, neither the OnGotFocus, nor the OnLostFocus methods fire
While this is not really an issue for me, I tried overriding the RadRichTextBox control to add my own behaviour to it, and found that if I override the OnGotFocus and OnLostFocus methods, they never get called. Something maybe to look at as part of this problem.
Please note that all these scenarios have been tried on a plan TextBox control, and it fires its GotFocus/LostFocus events as per my expected behaviour described. Therefore, I would expect the RadRichTextBox control to behave in the same manner.