Ticket T313092
Visible to All Users

Keyboard Focus is broken when selecting panels

created 9 years ago

When you select panels in a docklayoutmanager, the keyboard focus does not go to the inner content of the panels.

This was working in version 15.1.7.

Since I have the source code, the reason is that you've switched the LayoutPanel to using a new property called ContentPresenter. In version 15.1.7, you were using the Control property. Unfortunately, all your keyboard focus code is still passing in the Control property value as the root element to search for a focusable element. Control property now returns null.

While you are fixing this, if a software engineer reads this, can I offer more coding help? I recommend to install Resharper, your eyes will pop out your head with all the C# code warnings. Second, take a close look at KeyboardFocusHelper.cs. In GetElementToFocus(), on 1 line, there is "if (element is IInputElement)", and then right after the if, there is "if (element is FrameworkElement)". Well, the second if will never run because a FrameworkElement is a IInputElement. So what is the second if for? The same quirky 2 if statements can also be found in CanFocusResultCallback(). A UIElement is a IInputElement. So either the first if is redundant, or the second one. Also, testing for Focusable is not enough, you should include IsEnabled. See the method FocusHelper.CanBeFocused(), which does it right. That way, focus will go to an element that can actually receive focus. Although if nothing is enabled, the first focusable should be chosen.

(Note: Coupled with the fact that the PropertyGridControl is completely busted with a null exception immediately, which I see a ticket for, we'll be skipping 15.1.8.)

Answers approved by DevExpress Support

created 9 years ago

Hello Paul,

Usually, we avoid discussing multiple questions within the same thread because this makes it difficult to track the entire conversation. I have divided this thread into parts and moved them to separate threads:

  1. Keyboard Focus is broken when selecting panels;
    2. Resharper shows a lot of C# code warnings;
  2. Potential issues in the KeyboardFocusHelper class implementation;

Please refer to these threads for future discussion.

Thanks,
Michael

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.