Skip to content

Commit

Permalink
qml: Remove the swipe-to-close feature of the keyboard
Browse files Browse the repository at this point in the history
There have been numerous problems with this interaction over the years,
and the implementation to make swipe to close work is a bit spread around.
One consistent issue has been the keyboard getting stuck partly closed, and
swiping upward does nothing, while in some cases swiping upward could also
cause the keyboard to be moved partially off the screen. This implementation
would also be in conflict of possible implementation of skeyer swipe support
in the future. So just remove it for now.
  • Loading branch information
dobey committed Mar 14, 2024
1 parent a833db4 commit 89c514b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 130 deletions.
131 changes: 48 additions & 83 deletions qml/Keyboard.qml
Original file line number Diff line number Diff line change
Expand Up @@ -89,104 +89,69 @@ Item {

opacity: Keyboard.opacity

MouseArea {
id: swipeArea

property int jumpBackThreshold: Device.gu(10)
Page {
id: keyboardSurface
objectName: "keyboardSurface"

anchors.fill: parent

drag.target: keyboardSurface
drag.axis: Drag.YAxis;
drag.minimumY: 0
drag.maximumY: parent.height
//fix for lp:1277186
//only filter children when wordRibbon visible
drag.filterChildren: wordRibbon.visible
// Avoid conflict with extended key swipe selection and cursor swipe mode
enabled: !canvas.extendedKeysShown && !fullScreenItem.cursorSwipe

onReleased: {
if (keyboardSurface.y > jumpBackThreshold) {
MaliitGeometry.shown = false;
} else {
bounceBackAnimation.from = keyboardSurface.y
bounceBackAnimation.start();
}
}
WordRibbon {
id: wordRibbon
objectName: "wordRibbon"

Page {
id: keyboardSurface
objectName: "keyboardSurface"
// Hide thte word ribbon when in emoji or cursor mode
visible: !fullScreenItem.cursorSwipe && canvas.wordribbon_visible && keypad.state !== "EMOJI"

x:0
y:0
width: parent.width
height: canvas.height
anchors.bottom: keyboardComp.top
width: parent.width;

onXChanged: fullScreenItem.reportKeyboardVisibleRect();
onYChanged: fullScreenItem.reportKeyboardVisibleRect();
onWidthChanged: fullScreenItem.reportKeyboardVisibleRect();
// Use a size proportional to the height of keyboard keys
height: visible ? keypad.keyHeight * 0.5 : 0
onHeightChanged: fullScreenItem.reportKeyboardVisibleRect();

WordRibbon {
id: wordRibbon
objectName: "wordRibbon"

// Hide thte word ribbon when in emoji or cursor mode
visible: !fullScreenItem.cursorSwipe && canvas.wordribbon_visible && keypad.state !== "EMOJI"

anchors.bottom: keyboardComp.top
width: parent.width;

// Use a size proportional to the height of keyboard keys
height: visible ? keypad.keyHeight * 0.5 : 0
onHeightChanged: fullScreenItem.reportKeyboardVisibleRect();
}
}

ActionsToolbar {
id: toolbar
objectName: "actionsToolbar"
ActionsToolbar {
id: toolbar
objectName: "actionsToolbar"

visible: fullScreenItem.cursorSwipe
height: Device.wordRibbonHeight
}
visible: fullScreenItem.cursorSwipe
height: Device.wordRibbonHeight
}

Rectangle {
width: parent.width
height: 1
color: "#888888"
anchors.bottom: wordRibbon.visible ? wordRibbon.top : keyboardComp.top
}
Rectangle {
width: parent.width
height: 1
color: "#888888"
anchors.bottom: wordRibbon.visible ? wordRibbon.top : keyboardComp.top
}

Item {
id: keyboardComp
objectName: "keyboardComp"
Item {
id: keyboardComp
objectName: "keyboardComp"

visible: !fullScreenItem.cursorSwipe
height: parent.height
width: parent.width
anchors.bottom: parent.bottom
visible: !fullScreenItem.cursorSwipe
height: parent.height
width: parent.width
anchors.bottom: parent.bottom

onHeightChanged: fullScreenItem.reportKeyboardVisibleRect();
onHeightChanged: fullScreenItem.reportKeyboardVisibleRect();

KeyboardContainer {
id: keypad
KeyboardContainer {
id: keypad

anchors.fill: parent
anchors.topMargin: wordRibbon.visible ? 0 : Device.top_margin
anchors.bottomMargin: Device.bottom_margin
}
anchors.fill: parent
anchors.topMargin: wordRibbon.visible ? 0 : Device.top_margin
anchors.bottomMargin: Device.bottom_margin
}

LanguageMenu {
id: languageMenu
objectName: "languageMenu"
anchors.centerIn: parent
height: contentHeight > keypad.height ? keypad.height : contentHeight
width: Device.gu(30);
}
} // keyboardComp
}
LanguageMenu {
id: languageMenu
objectName: "languageMenu"
anchors.centerIn: parent
height: contentHeight > keypad.height ? keypad.height : contentHeight
width: Device.gu(30);
}
} // keyboardComp
}

PropertyAnimation {
Expand Down Expand Up @@ -283,7 +248,7 @@ Item {
topMargin: toolbar.height
}

enabled: cursorSwipe
enabled: fullScreenItem.cursorSwipe

// An invisible text field to be able to get selection colors from
// thte qqc2 style in use, for selection mode
Expand Down
8 changes: 0 additions & 8 deletions qml/keys/CharKey.qml
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,4 @@ Item {
keyMouseArea.evaluateSelectorSwipe();
}
}

Connections {
target: swipeArea.drag
function onActiveChanged() {
if (swipeArea.drag.active)
keyMouseArea.cancelPress();
}
}
}
39 changes: 0 additions & 39 deletions qml/keys/PressArea.qml
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,6 @@ MultiPointTouchArea {
swipedOut = true;
cancelPress();
}

// Dirty hack, see onReleased below
if (point.y > panel.height) {
// Touch point released past height of keyboard.
return;
}

var distance = point.y - lastY;
// If changing direction wait until movement passes 1 gu
// to avoid jitter
if ((lastYChange * distance > 0 || Math.abs(distance) > Device.gu(1)) && !held) {
keyboardSurface.y += distance;
lastY = point.y;
lastYChange = distance;
}
// Hide if we get close to the bottom of the screen.
// This works around issues with devices with touch buttons
// below the screen preventing release events when swiped
// over
if(point.sceneY > fullScreenItem.height - Device.gu(4) && point.y > startY + Device.gu(8) && !held) {
Keyboard.hide();
}
} else {
lastY = point.y;
}
Expand Down Expand Up @@ -139,23 +117,6 @@ MultiPointTouchArea {
}

onReleased: {
// Don't evaluate if the release point is above the start point
// or further away from its start than the height of the whole keyboard.
// This works around touches sometimes being recognized as ending below
// the bottom of the screen.
if (point.y > panel.height) {
console.warn("Touch point released past height of keyboard. Ignoring.");
} else if (!(point.y <= startY)) {
// Handles swiping away the keyboard
// Hide if the end point is more than 8 grid units from the start
if (!held && point.y > startY + Device.gu(8)) {
Keyboard.hide();
} else {
bounceBackAnimation.from = keyboardSurface.y;
bounceBackAnimation.start();
}
}

pressed = false;
held = false;
holdTimer.stop();
Expand Down

0 comments on commit 89c514b

Please sign in to comment.