[gnome-maps/wip/mlundblad/touch-gestures: 31/32] contextMenu: Add a long-press gesture to activate on touch



commit cb2617ab4ed85f13bead1db2392619c212d3cebf
Author: Marcus Lundblad <ml update uu se>
Date:   Mon Oct 16 22:21:32 2017 +0200

    contextMenu: Add a long-press gesture to activate on touch
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709605

 src/contextMenu.js |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 5306093..b737d40 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -72,6 +72,23 @@ var ContextMenu = new Lang.Class({
                                        this._routingUpdate.bind(this));
         this._routeItem.visible = false;
         this._routingUpdate();
+        this._initLongPress();
+    },
+
+    _initLongPress: function() {
+        this._longPressGesture =
+            new Gtk.GestureLongPress({ widget: this._mapView, 'touch-only': true });
+        this._longPressGesture.connect('pressed', this._onLongPress.bind(this));
+    },
+
+    _onLongPress: function(gesture, x, y) {
+        this._longitude = this._mapView.view.x_to_longitude(x);
+        this._latitude = this._mapView.view.y_to_latitude(y);
+        Mainloop.idle_add((function() {
+            let sequence = gesture.get_last_updated_sequence();
+
+            this.popup_at_pointer(gesture.get_last_event(sequence));
+        }).bind(this));
     },
 
     _onButtonReleaseEvent: function(widget, event) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]