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



commit d28375c7ddee5efe94a1ea4f2e8cefcf0fe5ca43
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]