summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-05-10 02:04:18 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-05-10 02:04:18 (GMT)
commit6ab242e23832f0ab10ef26a3b7b505cf086ddf43 (patch)
tree1fcb69478827d8efb5379bbd2219185a908071e5
parentb524e356424fe386eae56f65600077ce52ca6f92 (diff)
downloadQt-6ab242e23832f0ab10ef26a3b7b505cf086ddf43.zip
Qt-6ab242e23832f0ab10ef26a3b7b505cf086ddf43.tar.gz
Qt-6ab242e23832f0ab10ef26a3b7b505cf086ddf43.tar.bz2
Prevent handling of Up/Down on Mac OS X, for consistency with other platforms.
Task-number: QTBUG-10438
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp9
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp8
2 files changed, 15 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 9ae4e1a..604f508 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -62,6 +62,9 @@ QT_BEGIN_NAMESPACE
Input constraints include setting a QValidator, an input mask, or a
maximum input length.
+
+ On Mac OS X, the Up/Down key bindings for Home/End are explicitly disabled.
+ If you want such bindings (on any platform), you will need to construct them in QML.
*/
QDeclarativeTextInput::QDeclarativeTextInput(QDeclarativeItem* parent)
: QDeclarativePaintedItem(*(new QDeclarativeTextInputPrivate), parent)
@@ -860,10 +863,12 @@ void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus)
void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev)
{
Q_D(QDeclarativeTextInput);
- if(((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
+ if (((ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down) && ev->modifiers() == Qt::NoModifier) // Don't allow MacOSX up/down support, and we don't allow a completer.
+ || (((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
|| (d->control->cursor() == d->control->text().length()
&& ev->key() == Qt::Key_Right))
- && (d->lastSelectionStart == d->lastSelectionEnd)){
+ && (d->lastSelectionStart == d->lastSelectionEnd)))
+ {
//ignore when moving off the end
//unless there is a selection, because then moving will do something (deselect)
ev->ignore();
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 0065ccf..c00390d 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -576,6 +576,14 @@ void tst_qdeclarativetextinput::navigation()
simulateKey(canvas, Qt::Key_Left);
QVERIFY(input->hasFocus() == true);
+ // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438).
+ input->setCursorPosition(2);
+ QCOMPARE(input->cursorPosition(),2);
+ simulateKey(canvas, Qt::Key_Up);
+ QCOMPARE(input->cursorPosition(),2);
+ simulateKey(canvas, Qt::Key_Down);
+ QCOMPARE(input->cursorPosition(),2);
+
delete canvas;
}