コード例 #1
0
        public override FocusType GetFocusType(IAccessible accessibleObject, out string url)
        {
            url = null;

            // Walk up tree finding parent
            var parent = accessibleObject;

            while (parent != null)
            {
                var role = AccessibleObjectHelper.GetRole(parent);
                if (role == AccessibleRole.Text && AccessibleObjectHelper.HasState(accessibleObject, AccessibleStates.Focusable))
                {
                    // Could be the location bar, if the parent is a grouping
                    if (accessibleObject.accParent is IAccessible immediateParent)
                    {
                        if (AccessibleObjectHelper.GetRole(immediateParent) == AccessibleRole.Grouping && (AccessibleStates)immediateParent.accState[0] == AccessibleStates.None)
                        {
                            return(FocusType.Location);
                        }
                        else
                        {
                            if (AccessibleObjectHelper.FindAncestor(immediateParent, AccessibleRole.Dialog) != null)
                            {
                                return(FocusType.FindInPage);
                            }
                        }
                    }
                }
                parent = parent.accParent as IAccessible;
            }

            return(FocusType.Other);
        }
コード例 #2
0
        public override FocusType GetFocusType(IAccessible accessibleObject, out string url)
        {
            url = null;

            // Walk up tree finding parent
            var parent = accessibleObject;

            while (parent != null)
            {
                var role = AccessibleObjectHelper.GetRole(parent);
                if (role == AccessibleRole.ToolBar)
                {
                    // This is on the toolbar, so either location box or search box
                    if (accessibleObject.accParent is IAccessible immediateParent)
                    {
                        if (AccessibleObjectHelper.GetRole(immediateParent) == AccessibleRole.ComboBox)
                        {
                            if (AccessibleObjectHelper.HasState(accessibleObject, AccessibleStates.HasPopup))
                            {
                                return(FocusType.Location);
                            }
                            else
                            {
                                return(FocusType.Search);
                            }
                        }
                        else
                        {
                            if (parent.accParent is IAccessible propertyPage &&
                                AccessibleObjectHelper.GetRole(propertyPage) == AccessibleRole.PropertyPage)
                            {
                                // Get URL for page
                                var document = AccessibleObjectHelper.FindChild(AccessibleObjectHelper.FindChild(propertyPage),
                                                                                role: AccessibleRole.Document);
                                if (document != null)
                                {
                                    url = AccessibleObjectHelper.GetValue(document);
                                }
                            }

                            return(FocusType.FindInPage);
                        }
                    }
                }
                else if (role == AccessibleRole.Document && AccessibleObjectHelper.HasState(accessibleObject, AccessibleStates.Focusable))
                {
                    // This is a web page
                    url = AccessibleObjectHelper.GetValue(parent);
                    return(FocusType.Page);
                }
                parent = parent.accParent as IAccessible;
            }

            return(FocusType.Other);
        }
コード例 #3
0
        public override FocusType GetFocusType(IAccessible accessibleObject, out string url)
        {
            url = null;

            // Walk up tree finding parent
            var parent = accessibleObject;

            while (parent != null)
            {
                var role = AccessibleObjectHelper.GetRole(parent);
                if (role == AccessibleRole.Document && AccessibleObjectHelper.HasState(accessibleObject, AccessibleStates.Focusable))
                {
                    // This is a web page
                    url = AccessibleObjectHelper.GetValue(parent);
                    return(FocusType.Page);
                }

                parent = parent.accParent as IAccessible;
            }

            return(FocusType.Other);
        }