diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2013-02-25 16:48:54 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-01 19:07:59 +0100 |
commit | c791195ae72c4eb1ffc9755b03819c03cc621f3b (patch) | |
tree | 02cfa58177cc5dac305780c333e47fc4a3d39a78 /src/controls/TextArea.qml | |
parent | c2e4db37b824d7eb180d407b74c62916de234bd3 (diff) | |
download | qtquickcontrols-c791195ae72c4eb1ffc9755b03819c03cc621f3b.tar.gz qtquickcontrols-c791195ae72c4eb1ffc9755b03819c03cc621f3b.tar.bz2 qtquickcontrols-c791195ae72c4eb1ffc9755b03819c03cc621f3b.zip |
ScrollView & TextArea: fix vertical scrollbar visibility
Avoid binding loops by using recursion guards...
Change-Id: I1fb9f4ac54d6fa3cf930a848e22ec6b23edfa200
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/controls/TextArea.qml')
-rw-r--r-- | src/controls/TextArea.qml | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index 4f1442cb..49e31bdb 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -616,6 +616,31 @@ ScrollView { z: -1 } + property bool recursionGuard: false + + function doLayout() { + if (!recursionGuard) { + recursionGuard = true + if (wrapMode == TextEdit.NoWrap) { + horizontalScrollBar.visible = edit.paintedWidth + (2 * documentMargins) > area.viewport.width + edit.width = edit.paintedWidth + (2 * documentMargins) + } else { + horizontalScrollBar.visible = false + edit.width = area.viewport.width - (2 * documentMargins) + } + edit.height = Math.max(area.viewport.height - (2 * documentMargins), paintedHeight + (2 * documentMargins)) + recursionGuard = false + } + } + + Connections { + target: area.viewport + onWidthChanged: edit.doLayout() + onHeightChanged: edit.doLayout() + } + onPaintedWidthChanged: edit.doLayout() + onPaintedHeightChanged: edit.doLayout() + onWrapModeChanged: edit.doLayout() renderType: Text.NativeRendering @@ -623,8 +648,6 @@ ScrollView { selectionColor: palette.highlight selectedTextColor: palette.highlightedText wrapMode: TextEdit.WordWrap - width: area.viewport.width - (2 * documentMargins) - height: Math.max(area.viewport.height - (2 * documentMargins), paintedHeight + (2 * documentMargins)) x: documentMargins y: documentMargins |