diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2014-07-28 14:27:04 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@digia.com> | 2014-07-28 15:19:48 +0200 |
commit | 9304d512d4162e4a9c4508d90646d30ee7b4f5fd (patch) | |
tree | 7628465061f6eacedcc5549610c5c9301490f598 /src/controls/Private/TextHandle.qml | |
parent | 0d2a1d22aa9be63c7f751e822140238fc52936fa (diff) | |
download | qtquickcontrols-9304d512d4162e4a9c4508d90646d30ee7b4f5fd.tar.gz |
Fix TextHandle min/max position handling
When not explicitly specified, the maximum is the length of the editor
content, not minus one (cursor can be moved "past" the last character).
Furthermore, due to binding evaluation orders, the minimum/maximum
properties might be temporarily pointing outside the range so we must
validate them to avoid clients (TextField/TextArea) having to do that.
Change-Id: I1faddd1e7ac4f12d7a802484ceb8eea500ad8bfc
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/controls/Private/TextHandle.qml')
-rw-r--r-- | src/controls/Private/TextHandle.qml | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/controls/Private/TextHandle.qml b/src/controls/Private/TextHandle.qml index 147f61fa..558d0fa3 100644 --- a/src/controls/Private/TextHandle.qml +++ b/src/controls/Private/TextHandle.qml @@ -93,7 +93,7 @@ Loader { // limit vertically within mix/max coordinates or content bounds var min = (minimum !== -1) ? minimum : 0 - var max = (maximum !== -1) ? maximum : editor.length - 1 + var max = (maximum !== -1) ? maximum : editor.length pt.y = Math.max(pt.y, editor.positionToRectangle(min).y) pt.y = Math.min(pt.y, editor.positionToRectangle(max).y) @@ -102,8 +102,10 @@ Loader { // limit horizontally within min/max character positions if (minimum !== -1) pos = Math.max(pos, minimum) + pos = Math.max(pos, 0) if (maximum !== -1) pos = Math.min(pos, maximum) + pos = Math.min(pos, editor.length) handle.position = pos } |