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

Menu item physical click retains focus

1 Answer 62 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Loy Chan
Top achievements
Rank 1
Loy Chan asked on 21 Nov 2008, 04:29 PM
I have a Radmenu that I use to switch between different views on my spreadsheet control.

My click event will call a method to flip the active sheet on my spreadsheet control and then set the focus to that control.

The odd thing is that if I physically click the menu item, the focus will move to my spreadsheet control and then immediately go back to the menu item. But if I use the keyboard and press "space" on the menu item, the focus will remain on the spreadsheet control (as expected).

I tested this with a sample app that has a radmenu with 2 items, and two buttons. Each menu item will set the focus to a button. Each button has a Enter and Leave event that updates the text of the button.  The behaviour I'm noticing is replicated in this project.

    public partial class Form1 : Form  
    {  
        public Form1()  
        {  
            InitializeComponent();  
        }  
 
        private void button1_Enter(object sender, EventArgs e)  
        {  
            button1.Text = "got focus";  
        }  
 
        private void button1_Leave(object sender, EventArgs e)  
        {  
            button1.Text = "lost focus";  
        }  
 
        private void radMenuItem1_Click(object sender, EventArgs e)  
        {  
            button1.Focus();  
        }  
 
        private void radMenuItem2_Click(object sender, EventArgs e)  
        {  
            button2.Focus();  
        }  
 
        private void button2_Enter(object sender, EventArgs e)  
        {  
            button2.Text = "got focus";  
        }  
 
        private void button2_Leave(object sender, EventArgs e)  
        {  
            button2.Text = "lost focus";  
        }  
    } 

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 25 Nov 2008, 03:01 PM
Hi Loy Chan,

Thank you for contacting us.

This issue appears only when clicking on main menu items. Actually, the focusing of RadMenu can't be disabled. I would suggest moving your logic inside the MouseUp event of the desired menu item. Another approach would be to use RadToolStrip instead of RadMenu.

Should you have other questions I will be glad helping you.
 

Sincerely yours,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Menu
Asked by
Loy Chan
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or