summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2012-10-22 16:39:35 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-25 14:10:04 +0200
commit611c0081ff265354405882b40b323d7cb20ca967 (patch)
tree25e9c9f416707349209985e41493af8279408ac1 /src/widgets
parent50e7a5b7239f45c782f1814c185a1cdef31748d8 (diff)
Mac: Non-editable QComboBoxes shouldn't get focus by default
On Mac, only line edits and list views always get tab focus. It's only when we enable full keyboard access that other controls can get tab focus. When it's not editable, a combobox looks like a button, and it behaves as such in this respect. Change-Id: Ia31b0ad01b48a47c1b81180364681d8614863106 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qcombobox.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 16de0da4ac..74b3dc77d3 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -919,7 +919,17 @@ QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent)
void QComboBoxPrivate::init()
{
Q_Q(QComboBox);
- q->setFocusPolicy(Qt::WheelFocus);
+#ifdef Q_OS_MAC
+ // On Mac, only line edits and list views always get tab focus. It's only
+ // when we enable full keyboard access that other controls can get tab focus.
+ // When it's not editable, a combobox looks like a button, and it behaves as
+ // such in this respect.
+ if (!q->isEditable())
+ q->setFocusPolicy(Qt::TabFocus);
+ else
+#endif
+ q->setFocusPolicy(Qt::WheelFocus);
+
q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed,
QSizePolicy::ComboBox));
setLayoutItemMargins(QStyle::SE_ComboBoxLayoutItem);
@@ -1655,6 +1665,10 @@ void QComboBox::setEditable(bool editable)
}
QLineEdit *le = new QLineEdit(this);
setLineEdit(le);
+#ifdef Q_OS_MAC
+ // See comment in QComboBoxPrivate::init()
+ setFocusPolicy(Qt::WheelFocus);
+#endif
} else {
if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) {
d->viewContainer()->updateScrollers();
@@ -1664,6 +1678,10 @@ void QComboBox::setEditable(bool editable)
d->lineEdit->hide();
d->lineEdit->deleteLater();
d->lineEdit = 0;
+#ifdef Q_OS_MAC
+ // See comment in QComboBoxPrivate::init()
+ setFocusPolicy(Qt::TabFocus);
+#endif
}
d->viewContainer()->updateTopBottomMargin();