diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-12-30 16:41:45 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-01-01 11:35:39 -0800 |
commit | 765c4f9704e2b606a94fedff3e3fdf7deeefa2f6 (patch) | |
tree | 87b8f6f497e8da3e9b8b40dd9a99bab30238e84d /mobile-widgets/qml/SsrfTextField.qml | |
parent | d5a7ceb4334aafc4c8cd01c6e8281322cbf9113c (diff) | |
download | subsurface-765c4f9704e2b606a94fedff3e3fdf7deeefa2f6.tar.gz |
mobile/UI: fix the logic to keep input visible
Using the y coordinate of the component directly doesn't work if we use
the component inside other components. Instead we need to grab the
position relative to the flickable.
The comment about needing the function for this to work seemed dubious.
So for now I've removed that function and am setting the position
directly.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qml/SsrfTextField.qml')
-rw-r--r-- | mobile-widgets/qml/SsrfTextField.qml | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/mobile-widgets/qml/SsrfTextField.qml b/mobile-widgets/qml/SsrfTextField.qml index 84b7695b7..deba32a56 100644 --- a/mobile-widgets/qml/SsrfTextField.qml +++ b/mobile-widgets/qml/SsrfTextField.qml @@ -42,15 +42,11 @@ Controls.TextField { return } // make sure there's enough space for the input field above the keyboard and action button (and that it's not too far up, either) - if (stf.y + stf.height > flickable.contentY + flickable.height - 3 * Kirigami.Units.gridUnit || y < flickable.contentY) - ensureVisible(Math.max(0, 3 * Kirigami.Units.gridUnit + stf.y + stf.height - flickable.height)) + var positionInFlickable = stf.mapToItem(flickable.contentItem, 0, 0) + var stfY = positionInFlickable.y + console.log("position check: lower edge of view is " + (0 + flickable.contentY + flickable.height) + " and text field is at " + stfY) + if (stfY + stf.height > flickable.contentY + flickable.height - 3 * Kirigami.Units.gridUnit || stfY < flickable.contentY) + flickable.contentY = Math.max(0, 3 * Kirigami.Units.gridUnit + stfY + stf.height - flickable.height) } } - - // scroll the flickable to the desired position if the keyboard has shown up - // this didn't work when setting it from within the Timer, but calling this function works. - // go figure. - function ensureVisible(yDest) { - flickable.contentY = yDest - } } |