tdf#122572: Temporarily resurrect the context toolbar, for the iOS app only

It will be superseded by the context menu, but that doesn't work even
in normal Online in this branch currently. Once it works, I can then
try to use the same styling for it in the iOS app as for the context
toolbar, to make it look like the native iOS "edit menu".

This reverts a3d9cf8999ac25bb2b2a5d6332d7ac6e2f7c7350, but for the iOS
app only.

Note that there are other problems related to copy and paste in this
branch in the iOS app. The copy/paste changes for normal Online have
caused regressions in the app.

Reviewed-on: https://gerrit.libreoffice.org/76192
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
(cherry picked from commit 5448916f98c1480cfbc64f58e6d4f1cdb3fd133f)

Change-Id: I5c13cd0a5ece9038aba774b229dd86ec9c6678fc
Reviewed-on: https://gerrit.libreoffice.org/77781
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
This commit is contained in:
Tor Lillqvist 2019-07-23 16:44:41 +03:00
parent f8bb16d471
commit c7b1159f36

View file

@ -19,6 +19,10 @@ L.Map.TouchGesture = L.Handler.extend({
L.Handler.prototype.initialize.call(this, map);
this._state = L.Map.TouchGesture.MAP;
if (window.ThisIsTheiOSApp && !this._toolbar) {
this._toolbar = L.control.contextToolbar();
}
if (!this._hammer) {
this._hammer = new Hammer(this._map._mapPane);
this._hammer.get('swipe').set({
@ -83,6 +87,8 @@ L.Map.TouchGesture = L.Handler.extend({
this._hammer.on('pinchstart pinchmove', L.bind(this._onPinch, this));
this._hammer.on('pinchend', L.bind(this._onPinchEnd, this));
this._hammer.on('tripletap', L.bind(this._onTripleTap, this));
if (window.ThisIsTheiOSApp)
this._map.on('input.press', this._onInputPressiOSOnly, this);
this._map.on('updatepermission', this._onPermission, this);
this._onPermission({perm: this._map._permission});
},
@ -150,10 +156,23 @@ L.Map.TouchGesture = L.Handler.extend({
latlng = this._map.layerPointToLatLng(layerPoint),
mousePos = this._map._docLayer._latLngToTwips(latlng);
this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
// send right click to trigger context menus
this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 4, 0);
this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 4, 0);
if (window.ThisIsTheiOSApp) {
if (!this._toolbar._map && this._map._docLayer.containsSelection(latlng)) {
this._toolbar._pos = containerPoint;
this._toolbar.addTo(this._map);
} else {
this._toolbar.remove();
this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
// send right click to trigger context menus
this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 4, 0);
this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 4, 0);
}
} else {
this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
// send right click to trigger context menus
this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 4, 0);
this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 4, 0);
}
e.preventDefault();
},
@ -165,6 +184,8 @@ L.Map.TouchGesture = L.Handler.extend({
latlng = this._map.layerPointToLatLng(layerPoint),
mousePos = this._map._docLayer._latLngToTwips(latlng);
if (window.ThisIsTheiOSApp)
this._toolbar.remove();
this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
@ -291,6 +312,13 @@ L.Map.TouchGesture = L.Handler.extend({
}
},
_onInputPressiOSOnly: function (e) {
var pos = this._map.latLngToContainerPoint(e);
this._toolbar.remove();
this._toolbar._pos = pos;
this._toolbar.addTo(this._map);
},
_constructFakeEvent: function (evt, type) {
var fakeEvt = {
type: type,