aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextinput.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@digia.com>2013-11-21 11:06:24 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-22 10:08:56 +0100
commit802921d40b8b48239958c6035c74d986fe606860 (patch)
tree1cedbc16bf2c9217d60129dd77af62b2d4410abc /src/quick/items/qquicktextinput.cpp
parent88262738a8109f393f5e34d5898d1610d490e6f6 (diff)
TextInput: add editingFinished signal
Autotest is included. Task-number: QTBUG-34780 [ChangeLog][QtDeclarative][TextInput] add editingFinished signal Change-Id: Ib633daee67cd4e5f15739a6004adbe882ab3d3fc Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'src/quick/items/qquicktextinput.cpp')
-rw-r--r--src/quick/items/qquicktextinput.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 93ea677d2c..b46387ba47 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -1212,6 +1212,17 @@ bool QQuickTextInput::hasAcceptableInput() const
state.
*/
+/*!
+ \qmlsignal QtQuick::TextInput::onEditingFinished()
+ \since 5.2
+
+ This handler is called when the Return or Enter key is pressed or
+ the text input loses focus. Note that if there is a validator or
+ inputMask set on the text input and enter/return is pressed, this
+ handler will only be called if the input follows
+ the inputMask and the validator returns an acceptable state.
+*/
+
#ifndef QT_NO_IM
Qt::InputMethodHints QQuickTextInputPrivate::effectiveInputMethodHints() const
{
@@ -2522,6 +2533,9 @@ void QQuickTextInputPrivate::handleFocusEvent(QFocusEvent *event)
&& !persistentSelection)
deselect();
+ if (hasAcceptableInput(m_text) || fixup())
+ emit q->editingFinished();
+
#ifndef QT_NO_IM
q->disconnect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
q, SLOT(q_updateAlignment()));
@@ -4105,6 +4119,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event)
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
if (hasAcceptableInput(m_text) || fixup()) {
emit q->accepted();
+ emit q->editingFinished();
}
event->ignore();
return;