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

Textbox will not remain in focus on when in Menu

2 Answers 67 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Dev
Top achievements
Rank 1
Dev asked on 28 Jan 2013, 08:15 PM
I have added a text box into a menu with the following code. 

<telerik:RadMenuItem x:Name="EmployeeLookupMenuItem" StaysOpenOnClick="True" >
     <telerik:RadMenuItem.Header>
          <StackPanel>
               <telerik:RadWatermarkTextBox Name="EmployeeLookupTextBox" KeyUp="EmployeeLookupTextBox_KeyUp" WatermarkContent="Employee ID" Width="100" />
          </StackPanel>
     </telerik:RadMenuItem.Header>
</telerik:RadMenuItem>

The text box appears however when I click in it to type something it will only stay in focus while the mouse button is down. As soon as I release the mouse button it loses focus and I can no longer type in the box.

Why can I not type in the textbox?

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosen Vladimirov
Telerik team
answered on 29 Jan 2013, 07:03 AM
Hi Tom,

I've tested your problem and the issue is reproduced only when you click at the end of RadWaterMarkTextBox - if you click directly in the center, you will be able to type. The problem is that at the end of the control there isn't a TextBox which handles the mouse events if you click in the center. So these mouse events are catched by RadMenuItem and treated as click. This is the expected behavior. If you want to write in RadWaterMarkTextBox, no matter where you've clicked, you should "catch" MouseLeftButtonUp event before RadMenuItem. Here is how to achieve this:
<telerik:RadMenuItem Header="Item 1">
    <telerik:RadMenuItem x:Name="EmployeeLookupMenuItem" StaysOpenOnClick="True">
        <telerik:RadMenuItem.Header>
            <StackPanel>
                <telerik:RadWatermarkTextBox Name="EmployeeLookupTextBox" KeyUp="EmployeeLookupTextBox_KeyUp_1" WatermarkContent="Employee ID" Width="100" MouseLeftButtonUp="EmployeeLookupTextBox_MouseLeftButtonUp_1"/>
            </StackPanel>
        </telerik:RadMenuItem.Header>
    </telerik:RadMenuItem>
</telerik:RadMenuItem>

And in code behind:
private void EmployeeLookupTextBox_KeyUp_1(object sender, KeyEventArgs e)
{
    e.Handled = true;
}
 
private void EmployeeLookupTextBox_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e)
{
    e.Handled = true;
}

Please test it from your side and inform me if you still have any problems or concerns.

Greetings,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Dev
Top achievements
Rank 1
answered on 29 Jan 2013, 05:14 PM
This worked. Thank you.
Tags
Menu
Asked by
Dev
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Dev
Top achievements
Rank 1
Share this question
or