summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible.cpp20
-rw-r--r--src/gui/accessible/qaccessible.h2
-rw-r--r--src/gui/accessible/qaccessibleobject.cpp25
-rw-r--r--src/gui/accessible/qaccessibleobject.h2
4 files changed, 27 insertions, 22 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index c65e7df327..7c23ede6fc 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -740,8 +740,11 @@ void QAccessible::updateAccessibility(QObject *o, int who, Event reason)
The functions childCount() and indexOfChild() return the number of
children of an accessible object and the index a child object has
- in its parent. The childAt() function returns the index of a child
- at a given position.
+ in its parent. The childAt() function returns a child QAccessibleInterface
+ that is found at a position. The child does not have to be a direct
+ child. This allows bypassing intermediate layers when the parent already knows the
+ top-most child. childAt() is used for hit testing (finding the object
+ under the mouse).
The relationTo() function provides information about how two
different objects relate to each other, and navigate() allows
@@ -875,18 +878,21 @@ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > QAccessibleInterfa
}
/*!
- \fn int QAccessibleInterface::childAt(int x, int y) const
+ \fn QAccessibleInterface *QAccessibleInterface::childAt(int x, int y) const
- Returns the 1-based index of the child that contains the screen
- coordinates (\a x, \a y). This function returns 0 if the point is
- positioned on the object itself. If the tested point is outside
- the boundaries of the object this function returns -1.
+ Returns the QAccessibleInterface of a child that contains the screen coordinates (\a x, \a y).
+ If there are no children at this position this function returns 0.
+ The returned accessible must be a child, but not necessarily a direct child.
This function is only relyable for visible objects (invisible
object might not be laid out correctly).
All visual objects provide this information.
+ A default implementation is provided for objects inheriting QAccessibleObject. This will iterate
+ over all children. If the widget manages its children (e.g. a table) it will be more efficient
+ to write a specialized implementation.
+
\sa rect()
*/
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index 6ee1885a3d..3831b7d8e1 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -369,7 +369,7 @@ public:
virtual QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
virtual QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > relations() const;
- virtual int childAt(int x, int y) const = 0;
+ virtual QAccessibleInterface *childAt(int x, int y) const = 0;
// navigation, hierarchy
virtual QAccessibleInterface *parent() const = 0;
diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp
index 18941437fe..b3e9479013 100644
--- a/src/gui/accessible/qaccessibleobject.cpp
+++ b/src/gui/accessible/qaccessibleobject.cpp
@@ -154,6 +154,18 @@ void QAccessibleObject::setText(QAccessible::Text, const QString &)
{
}
+/*! \reimp */
+QAccessibleInterface *QAccessibleObject::childAt(int x, int y) const
+{
+ for (int i = 0; i < childCount(); ++i) {
+ QAccessibleInterface *childIface = child(i);
+ if (childIface->rect().contains(x,y)) {
+ return childIface;
+ }
+ }
+ return 0;
+}
+
/*!
\class QAccessibleApplication
\brief The QAccessibleApplication class implements the QAccessibleInterface for QApplication.
@@ -214,19 +226,6 @@ int QAccessibleApplication::indexOfChild(const QAccessibleInterface *child) cons
}
/*! \reimp */
-int QAccessibleApplication::childAt(int x, int y) const
-{
- for (int i = 0; i < childCount(); ++i) {
- QAccessibleInterface *childIface = child(i);
- QRect geom = childIface->rect();
- if (geom.contains(x,y))
- return i+1;
- delete childIface;
- }
- return rect().contains(x,y) ? 0 : -1;
-}
-
-/*! \reimp */
QAccessible::Relation QAccessibleApplication::relationTo(const QAccessibleInterface *other) const
{
QObject *o = other ? other->object() : 0;
diff --git a/src/gui/accessible/qaccessibleobject.h b/src/gui/accessible/qaccessibleobject.h
index f2a9fd0430..ac385fcc39 100644
--- a/src/gui/accessible/qaccessibleobject.h
+++ b/src/gui/accessible/qaccessibleobject.h
@@ -67,6 +67,7 @@ public:
// properties
QRect rect() const;
void setText(QAccessible::Text t, const QString &text);
+ QAccessibleInterface *childAt(int x, int y) const;
protected:
virtual ~QAccessibleObject();
@@ -89,7 +90,6 @@ public:
// navigation
QAccessibleInterface *parent() const;
- int childAt(int x, int y) const;
QAccessibleInterface *child(int index) const;
int navigate(QAccessible::RelationFlag, int, QAccessibleInterface **) const;