This is a migrated thread and some comments may be shown as answers.

RadTextBoxElement and the MouseLeave / Mouse Capture events

4 Answers 45 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
IT
Top achievements
Rank 1
IT asked on 19 Dec 2017, 08:52 AM

Hello team,

 

i got a RadRibbonBar, with RibbonBarGroups in it and one of the RadRibbonBarGroups contains a RadTextBoxElement. Im currently failing at the following goal:

- i want to catch the moment when the textbox looses the mouse focus.

Im using the MouseDown event to initiate the user interaction with the textbox and now i want an oposite to that, so that i can recognize if the user has "mousedowned" any other control on the screen.

I tried the MouseLeave event which seems not to be the totaly right thing, but still better than nothing - this even fires from time to time but i cant tell on which exact condition. Moving the mouse away from the textbox does not always trigger it.

The MouseLostCapture event - not sure if its right at all - didnt trigger even once.

Please tell what event should i use for my need?

 

Thank you!

 

 

 

 

 

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 19 Dec 2017, 09:31 AM
Hello,  

Thank you for writing.  

The appropriate events to handle in this case are the GotFocus and LostFocus event of the RadTextBoxElement.TextBoxItem:
public RadForm1()
{
    InitializeComponent();
 
    this.radTextBoxElement1.TextBoxItem.GotFocus+=TextBoxItem_GotFocus;
    this.radTextBoxElement1.TextBoxItem.LostFocus+=TextBoxItem_LostFocus;
}
 
private void TextBoxItem_LostFocus(object sender, EventArgs e)
{
    Console.WriteLine("LostFocus");
}
 
private void TextBoxItem_GotFocus(object sender, EventArgs e)
{
    Console.WriteLine("GotFocus");
}

There are fired when the RadTextBoxElement gets/loses the focus.

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
IT
Top achievements
Rank 1
answered on 19 Dec 2017, 10:58 AM
Thank you, that helped me a lot!
0
bla
Top achievements
Rank 1
Veteran
answered on 25 Feb 2021, 02:08 PM

Hi, I actually want the MouseLeave event which is definitely handles wrong byTelerik (or in my case at least the radSpinEditor).

When the outer border (1px) is crossed it is already fired although one is entering, not leaving! And when the curser leaves the control it is not fired in every case.

So how can we really realize when the mouse is over a control or not anymore???

0
Nadya
Telerik team
answered on 25 Feb 2021, 02:27 PM

Hello,

I would like to clarify that RadSpinEditor internally hosts the MS TextBox control. When you hover the spin editor control the MousEnter is invoked and then the mouse captures the hosted text box control. This results in firing the MouseLeave event of the control immediately after MouseEnter. This is why I can suggest handling the mouse events of the hosted text box control:

this.radSpinEditor1.SpinElement.TextBoxItem.HostedControl.MouseLeave += this.RadSpinEditor1_MouseLeave;
private void RadSpinEditor1_MouseLeave(object sender, EventArgs e)
{

}

I hope this information is useful. Do not hesitate to contact me if you have other questions.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TextBox
Asked by
IT
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
IT
Top achievements
Rank 1
bla
Top achievements
Rank 1
Veteran
Nadya
Telerik team
Share this question
or