diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-09-09 01:57:09 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-09-09 01:57:09 (GMT) |
commit | c253b86a77e8228479fec21c7237a54103ab95ee (patch) | |
tree | 851cdadc5a066ff6f0da292e9ce5c529339c0000 /src/declarative | |
parent | a626641fafcf5f3a2e904cd0679f62ee70e19f4e (diff) | |
download | Qt-c253b86a77e8228479fec21c7237a54103ab95ee.zip Qt-c253b86a77e8228479fec21c7237a54103ab95ee.tar.gz Qt-c253b86a77e8228479fec21c7237a54103ab95ee.tar.bz2 |
TextInput bug fixes
-Cursor is now visible when at the end of the line
-Left and Right key events are now ignored if it is at the end of the
line.
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/fx/qfxtextinput.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp index 4dd29cd..39a0187 100644 --- a/src/declarative/fx/qfxtextinput.cpp +++ b/src/declarative/fx/qfxtextinput.cpp @@ -480,6 +480,13 @@ void QFxTextInput::focusChanged(bool hasFocus) void QFxTextInput::keyPressEvent(QKeyEvent* ev) { Q_D(QFxTextInput); + if((d->control->cursor() == 0 && ev->key() == Qt::Key_Left) + || (d->control->cursor() == d->control->text().length() + && ev->key() == Qt::Key_Right)){ + //ignore moving off the end + ev->ignore(); + return; + } d->control->processKeyEvent(ev); if (!ev->isAccepted()) QFxPaintedItem::keyPressEvent(ev); @@ -500,6 +507,7 @@ bool QFxTextInput::event(QEvent* ev) Q_D(QFxTextInput); //Anything we don't deal with ourselves, pass to the control switch(ev->type()){ + case QEvent::KeyPress: case QEvent::GraphicsSceneMousePress: break; default: @@ -645,7 +653,8 @@ void QFxTextInput::updateSize() setImplicitHeight(d->control->height()); //d->control->width() is max width, not current width QFontMetrics fm = QFontMetrics(d->font); - setImplicitWidth(fm.boundingRect(d->control->text()).width()+1); + setImplicitWidth(fm.width(d->control->text())+1); + //setImplicitWidth(d->control->naturalWidth());//### This fn should be coming into 4.6 shortly, and might be faster setContentsSize(QSize(width(), height())); } |