summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qfxtextinput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/fx/qfxtextinput.cpp')
-rw-r--r--src/declarative/fx/qfxtextinput.cpp11
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()));
}