Example #1
0
        internal static bool IsFocusable(DependencyObject?dependencyObject)
        {
            bool isFocusable = false;

            var objectAsUI = dependencyObject as UIElement;

            if (objectAsUI != null && objectAsUI.SkipFocusSubtree)
            {
                return(false);
            }

            if (dependencyObject is Control control)
            {
                isFocusable = control.IsFocusable;
            }
            else if (FocusableHelper.GetIFocusableForDO(dependencyObject) is { } ifocusable)
            {
                isFocusable = ifocusable.IsFocusable();
            }
Example #2
0
        private Rect GetOriginToComponent(DependencyObject?pOldFocusedElement)
        {
            Rect focusedElementBounds = new Rect();

            //Transform the bounding rect of currently focused element to Component's co-ordinate space
            if (pOldFocusedElement != null)
            {
                if (FocusableHelper.GetIFocusableForDO(pOldFocusedElement) is { } focusable)
                {
                    //TODO Uno: Implement support for HyperLink focus
                    //DependencyObject depObj = focusable.GetDOForIFocusable();
                    //IFC_RETURN(do_pointer_cast<CTextElement>(depObj).GetContainingFrameworkElement().GetGlobalBounds(&focusedElementBounds, true));
                }
                else
                {
                    UIElement?pUIElement = pOldFocusedElement as UIElement;
                    if (pUIElement != null)
                    {
                        focusedElementBounds = pUIElement.GetGlobalBounds(true);
                    }
                }
            }
Example #3
0
        private static DependencyProperty?GetXYFocusNavigationStrategyPropertyIndex(
            DependencyObject element,
            FocusNavigationDirection direction)
        {
            DependencyProperty?property = null;

            if (element.IsRightToLeft())
            {
                if (direction == FocusNavigationDirection.Left)
                {
                    direction = FocusNavigationDirection.Right;
                }
                else if (direction == FocusNavigationDirection.Right)
                {
                    direction = FocusNavigationDirection.Left;
                }
            }

            if (direction == FocusNavigationDirection.Left)
            {
                if (element is UIElement)
                {
                    property = UIElement.XYFocusLeftNavigationStrategyProperty;
                }
                else if (FocusableHelper.GetIFocusableForDO(element) is IFocusable focusable)
                {
                    property = focusable.GetXYFocusLeftNavigationStrategyPropertyIndex();
                }
            }
            else if (direction == FocusNavigationDirection.Right)
            {
                if (element is UIElement)
                {
                    property = UIElement.XYFocusRightNavigationStrategyProperty;
                }
                else if (FocusableHelper.GetIFocusableForDO(element) is IFocusable focusable)
                {
                    property = focusable.GetXYFocusRightNavigationStrategyPropertyIndex();
                }
            }
            else if (direction == FocusNavigationDirection.Up)
            {
                if (element is UIElement)
                {
                    property = UIElement.XYFocusUpNavigationStrategyProperty;
                }
                else if (FocusableHelper.GetIFocusableForDO(element) is IFocusable focusable)
                {
                    property = focusable.GetXYFocusUpNavigationStrategyPropertyIndex();
                }
            }
            else if (direction == FocusNavigationDirection.Down)
            {
                if (element is UIElement)
                {
                    property = UIElement.XYFocusDownNavigationStrategyProperty;
                }
                else if (FocusableHelper.GetIFocusableForDO(element) is IFocusable focusable)
                {
                    property = focusable.GetXYFocusDownNavigationStrategyPropertyIndex();
                }
            }

            return(property);
        }