Exemple #1
0
 public override AccessibleObject HitTest(int x, int y)
 {
     try {
         object o = acc.accHitTest(x, y);
         return(Wrap(o));
     } catch (Exception) {
         return(null);
     }
 }
Exemple #2
0
        private void root_MouseDown(object sender, MouseEventArgs e)
        {
            Control          c           = sender as Control;
            AccessibleObject ao          = c.AccessibilityObject;
            Point            screenPoint = c.PointToScreen(new Point(e.X, e.Y));
            StringBuilder    sb          = new StringBuilder();

            System.Reflection.PropertyInfo pi = c.GetType().GetProperty("AccessibleRootObject");
            if (pi == null)
            {
                AccessibleObject aoPrev = null;                 // Some HitTests keep returning the leaf object.
                for (AccessibleObject aoCur = ao.HitTest(screenPoint.X, screenPoint.Y);
                     aoCur != null && aoCur != ao && aoCur != aoPrev;
                     aoCur = aoCur.HitTest(screenPoint.X, screenPoint.Y))
                {
                    if (sb.Length > 0)
                    {
                        sb.Append("/");
                    }
                    sb.Append(aoCur.Role);
                    sb.Append(":");
                    sb.Append(aoCur.Name);
                    aoPrev = aoCur;
                }
            }
            else
            {
                IAccessible acc = (IAccessible)pi.GetValue(c, new object[0]);

                for (IAccessible accCurr = (IAccessible)acc.accHitTest(screenPoint.X, screenPoint.Y);
                     accCurr != null;
                     accCurr = accCurr.accHitTest(screenPoint.X, screenPoint.Y) as IAccessible)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append("/");
                    }
                    sb.Append(InterpretRole(accCurr.get_accRole(null)));
                    sb.Append(":");
                    sb.Append(accCurr.get_accName(null));
                }
            }

            string leafPath = sb.ToString();

            m_output.WriteStartElement("click");
            m_output.WriteAttributeString("path", AccessPath(sender as Control));
            m_output.WriteAttributeString("at", "(" + e.X + "," + e.Y + ")");
            if (leafPath.Length > 0)
            {
                m_output.WriteAttributeString("child", leafPath);
            }
            m_output.WriteEndElement();
            m_output.WriteWhitespace("\n");
            m_output.Flush();
        }
        // GetHelptopic not yet delegated.
        // GetLifetimeService not delegated.
        // GetSelected not yet delegated.
        // GetType not delegated.

        /// <summary>
        /// Which child (or the recipient), if any, contains the point.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public override AccessibleObject HitTest(int x, int y)
        {
            IAccessible acc = (IAccessible)(m_acc.accHitTest(x, y));

            if (acc == null)
            {
                return(null);
            }
            if (acc == m_acc)
            {
                return(this);
            }
            return(new AccessibleObjectFromIAccessible(acc));
        }
Exemple #4
0
 object?IAccessibleInternal.accHitTest(int xLeft, int yTop)
 => AsNativeAccessible(publicIAccessible.accHitTest(xLeft, yTop));
 object UnsafeNativeMethods.IAccessibleInternal.accHitTest(int xLeft, int yTop)
 {
     IntSecurity.UnmanagedCode.Assert();
     return(AsNativeAccessible(publicIAccessible.accHitTest(xLeft, yTop)));
 }