Fix keyboard navigation order for buttons with RTL layout
On RTL layout, right key should move to previous button, and left key should move to next button. Task-number: QTBUG-15790 Change-Id: If0753f9082b3a3624b95276840f5f3799b5e14bf Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
parent
4f1820e3a7
commit
a4d0c56a59
@ -1178,11 +1178,11 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
case Qt::Key_Left:
|
|
||||||
next = false;
|
next = false;
|
||||||
// fall through
|
// fall through
|
||||||
|
case Qt::Key_Left:
|
||||||
case Qt::Key_Right:
|
case Qt::Key_Right:
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down: {
|
||||||
#ifdef QT_KEYPAD_NAVIGATION
|
#ifdef QT_KEYPAD_NAVIGATION
|
||||||
if ((QApplication::keypadNavigationEnabled()
|
if ((QApplication::keypadNavigationEnabled()
|
||||||
&& (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right))
|
&& (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right))
|
||||||
@ -1192,13 +1192,13 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
QWidget *pw;
|
QWidget *pw = parentWidget();
|
||||||
if (d->autoExclusive
|
if (d->autoExclusive
|
||||||
#ifndef QT_NO_BUTTONGROUP
|
#ifndef QT_NO_BUTTONGROUP
|
||||||
|| d->group
|
|| d->group
|
||||||
#endif
|
#endif
|
||||||
#ifndef QT_NO_ITEMVIEWS
|
#ifndef QT_NO_ITEMVIEWS
|
||||||
|| ((pw = parentWidget()) && qobject_cast<QAbstractItemView *>(pw->parentWidget()))
|
|| (pw && qobject_cast<QAbstractItemView *>(pw->parentWidget()))
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
// ### Using qobject_cast to check if the parent is a viewport of
|
// ### Using qobject_cast to check if the parent is a viewport of
|
||||||
@ -1209,9 +1209,17 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
|
|||||||
if (hasFocus()) // nothing happend, propagate
|
if (hasFocus()) // nothing happend, propagate
|
||||||
e->ignore();
|
e->ignore();
|
||||||
} else {
|
} else {
|
||||||
|
// Prefer parent widget, use this if parent is absent
|
||||||
|
QWidget *w = pw ? pw : this;
|
||||||
|
bool reverse = (w->layoutDirection() == Qt::RightToLeft);
|
||||||
|
if ((e->key() == Qt::Key_Left && !reverse)
|
||||||
|
|| (e->key() == Qt::Key_Right && reverse)) {
|
||||||
|
next = false;
|
||||||
|
}
|
||||||
focusNextPrevChild(next);
|
focusNextPrevChild(next);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Qt::Key_Escape:
|
case Qt::Key_Escape:
|
||||||
if (d->down) {
|
if (d->down) {
|
||||||
setDown(false);
|
setDown(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user