[Libreoffice-commits] online.git: loleaflet/src
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Tue Feb 11 14:47:42 UTC 2020
loleaflet/src/layer/tile/TileLayer.js | 3 +
loleaflet/src/map/handler/Map.TouchGesture.js | 46 ++++++++++++++++++++++----
2 files changed, 42 insertions(+), 7 deletions(-)
New commits:
commit 9fcd4d37778d9580cc7b425787c3a8c1d9e756dd
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Thu Jan 30 06:47:32 2020 -0500
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Feb 11 15:47:22 2020 +0100
leaflet: second tap in cell starts editing
Single taping and double taping now enter
cell-edit mode and show the keyboard.
And improve graphic selection and adding text.
Change-Id: Ib38aac3165078cf143009d9ace530027bf630432
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88034
Tested-by: Jan Holesovsky <kendy at collabora.com>
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 86471ef82..46bd3c0a7 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -2732,6 +2732,9 @@ L.TileLayer = L.GridLayer.extend({
// Update group layer selection handler.
_onUpdateGraphicSelection: function () {
if (this._graphicSelection && !this._isEmptyRectangle(this._graphicSelection)) {
+ // Hide the keyboard on graphic selection, unless cursor is visible.
+ this._map.focus(this.isCursorVisible());
+
if (this._graphicMarker) {
this._graphicMarker.removeEventParent(this._map);
this._graphicMarker.off('scalestart scaleend', this._onGraphicEdit, this);
diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index 5fb364ef9..4d8209761 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -327,13 +327,37 @@ L.Map.TouchGesture = L.Handler.extend({
}
this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
+ var acceptInput = false; // No keyboard by default.
+ var sendMouseEvents = true; // By default, this is a single-click.
if (docLayer) {
+ if (docLayer.hasGraphicSelection()) {
+ // Need keyboard when cursor is visible.
+ acceptInput = this._map._docLayer.isCursorVisible();
+ } else if (docLayer._docType === 'text') {
+ acceptInput = true; // Always show the keyboard in Writer on tap.
+ } else if (docLayer._docType === 'spreadsheet') {
+ // If the tap is in the current cell, start editing.
+ var cellCursor = docLayer._cellCursor;
+ acceptInput = (cellCursor && cellCursor.contains(latlng));
+ if (acceptInput) {
+ // Enter cell-edit mode on second tap of a selected cell.
+ if (this._map._permission === 'edit') {
+ docLayer.postKeyboardEvent('input', 0, 769); // F2
+ sendMouseEvents = false; // Mouse events will exit editing mode.
+ }
+
+ }
+ }
+ }
+
+ if (sendMouseEvents) {
docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
-
- // Take focus, but keyboard show only in Writer (double-tap to edit Calc/Impress).
- this._map.focus(this._map._docLayer._docType === 'text');
}
+
+ // Always move the focus to the document on tap,
+ // but only show the keyboard when we need editing.
+ this._map.focus(acceptInput);
},
_onDoubleTap: function (e) {
@@ -345,11 +369,19 @@ L.Map.TouchGesture = L.Handler.extend({
var docLayer = this._map._docLayer;
if (docLayer) {
- docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 2, 1, 0);
- docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 2, 1, 0);
+ if (docLayer._docType === 'spreadsheet' && !docLayer.hasGraphicSelection()) {
+ // Enter cell-edit mode on double-taping a cell.
+ if (this._map._permission === 'edit') {
+ docLayer.postKeyboardEvent('input', 0, 769); // F2
+ }
+ } else {
+ docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 2, 1, 0);
+ docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 2, 1, 0);
+ }
- // Show keyboard.
- this._map.focus(true);
+ // Show keyboard when no graphic selection, or cursor is visible.
+ var acceptInput = !docLayer.hasGraphicSelection() || docLayer.isCursorVisible();
+ this._map.focus(acceptInput);
}
},
More information about the Libreoffice-commits
mailing list