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

Prevent Focus

3 Answers 125 Views
CommandBar
This is a migrated thread and some comments may be shown as answers.
Hesham Desouky
Top achievements
Rank 2
Hesham Desouky asked on 19 Mar 2012, 05:38 PM
Is it possible to prevent the CommandBar getting focus from current focused control

3 Answers, 1 is accepted

Sort by
0
Boryana
Telerik team
answered on 21 Mar 2012, 05:57 PM
Hello Hesham, 

Thank you for writing.

If you would like prevent RadCommandBar from taking the focus, you can use set its TabStop property to false. In this way when the user presses Tab the control will be skipped.

In case I have misunderstood your requirement, I kindly ask you to provide more details on your scenario. A detailed explanation, code snippets, or screenshots are possible ways of conveying important information regarding your scenario. Once I am able to fully understand your case, I will do my best to provide you with solution.

Kind regards,
Boryana
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Hesham Desouky
Top achievements
Rank 2
answered on 22 Mar 2012, 09:06 AM
Hello Boryana,
Thanks for your prompt reply.

The scenario is when having certain control in the the form with focus, the focus is lost when clicking one of the RadCommandBar button. This is not related to tabstop but to the mouse clicks.
This is not true for RadMenu, RadMenu didn't receive focus when selecting one of the menu items while RadCommandBar elements receive focus when clicking any of the bar elements.

This causes user to lose the ability to e.g. scrolling the focused control using mouse scroll wheel before clicking the RadCommandBar button after performing the click

Which requires the user to click the required control again to be able to scroll.

I tried a technique to return focus to desired control after clicking RadCommandBar item, but I think this solution is not good because the unfocusing/focusing cues give the user odd experience

What you think
0
Boryana
Telerik team
answered on 26 Mar 2012, 02:22 PM
Hello,

Thank you for clarifying your scenario. 

You can easily avoid the default behavior of RadCommandBar through overriding the ProcessFocusRequested method. Create a class that derives from RadCommandBar and set its ThemeClassName property, so that the theming mechanism can theme it as a RadCommandBar. Further, override the ProcessFocusRequested method and make it always return false:
class MyCommandBar: RadCommandBar
{
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadCommandBar).FullName;
        }
    }
 
    protected override bool ProcessFocusRequested(RadElement element)
    {
        return false;
    }
}

The attached sample project demonstrates the above approach.

I hope this helps. Let me know if you have further questions.

Regards,
Boryana
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
CommandBar
Asked by
Hesham Desouky
Top achievements
Rank 2
Answers by
Boryana
Telerik team
Hesham Desouky
Top achievements
Rank 2
Share this question
or