Accessibility: Fix rect for QComboBox and QRadioButton
This is especially relevant on mobile devices where screen readers often send mouse clicks to the middle of the object. Task-number: QTBUG-39100 Change-Id: I5972f21dd12434601d86136215ab9b61248c9691 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
This commit is contained in:
parent
c040ba18ae
commit
e747324f68
@ -158,6 +158,26 @@ QAccessible::State QAccessibleButton::state() const
|
||||
return state;
|
||||
}
|
||||
|
||||
QRect QAccessibleButton::rect() const
|
||||
{
|
||||
QAbstractButton *ab = button();
|
||||
if (!ab->isVisible())
|
||||
return QRect();
|
||||
|
||||
if (QCheckBox *cb = qobject_cast<QCheckBox *>(ab)) {
|
||||
QPoint wpos = cb->mapToGlobal(QPoint(0, 0));
|
||||
QStyleOptionButton opt;
|
||||
cb->initStyleOption(&opt);
|
||||
return cb->style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, cb).translated(wpos);
|
||||
} else if (QRadioButton *rb = qobject_cast<QRadioButton *>(ab)) {
|
||||
QPoint wpos = rb->mapToGlobal(QPoint(0, 0));
|
||||
QStyleOptionButton opt;
|
||||
rb->initStyleOption(&opt);
|
||||
return rb->style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, rb).translated(wpos);
|
||||
}
|
||||
return QAccessibleWidget::rect();
|
||||
}
|
||||
|
||||
QStringList QAccessibleButton::actionNames() const
|
||||
{
|
||||
QStringList names;
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
|
||||
QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
|
||||
QAccessible::State state() const Q_DECL_OVERRIDE;
|
||||
QRect rect() const Q_DECL_OVERRIDE;
|
||||
|
||||
QStringList actionNames() const Q_DECL_OVERRIDE;
|
||||
void doAction(const QString &actionName) Q_DECL_OVERRIDE;
|
||||
|
@ -86,6 +86,7 @@ protected:
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QCheckBox)
|
||||
Q_DISABLE_COPY(QCheckBox)
|
||||
friend class QAccessibleButton;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -73,6 +73,7 @@ protected:
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QRadioButton)
|
||||
Q_DISABLE_COPY(QRadioButton)
|
||||
friend class QAccessibleButton;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user