branch: externals/osm commit 8e8e4583f57a4fd00415d63c967af3d7868effcd Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
More robust mouse dragging --- README.org | 2 +- osm.el | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 0faaa05271..03ca23fb60 100644 --- a/README.org +++ b/README.org @@ -72,7 +72,7 @@ Key bindings in =osm-mode= buffer: - ~<mouse-2>~: =osm-org-link-click= - Store point as Org link - ~<mouse-3>~: =osm-bookmark-set-click= - Store point as bookmark - ~<S-mouse-3>~: =osm-bookmark-delete-click= - Delete bookmark at point -- ~<down-mouse-1>~: =osm-drag= - Drag the map with the mouse +- ~<down-mouse-*>~: =osm-drag= - Drag the map with the mouse - ~g~: =osm-goto= - Go to location - ~h~: =osm-home= - Go to home location - ~s~: =osm-search= - Search for location diff --git a/osm.el b/osm.el index 9a49869c26..470e71b25d 100644 --- a/osm.el +++ b/osm.el @@ -140,6 +140,8 @@ Should be at least 7 days according to the server usage policies." (define-key map [mouse-3] #'osm-bookmark-set-click) (define-key map [S-mouse-3] #'osm-bookmark-delete-click) (define-key map [down-mouse-1] #'osm-drag) + (define-key map [down-mouse-2] #'osm-drag) + (define-key map [down-mouse-3] #'osm-drag) (define-key map [up] #'osm-up) (define-key map [down] #'osm-down) (define-key map [left] #'osm-left) @@ -357,12 +359,17 @@ Should be at least 7 days according to the server usage policies." (define-key map [mouse-movement] (lambda (event) (interactive "@e") + (define-key map [mouse-1] #'ignore) + (define-key map [mouse-2] #'ignore) + (define-key map [mouse-3] #'ignore) (pcase-let ((`(,ex . ,ey) (posn-x-y (event-start event)))) (setq osm--x (- sx ex) osm--y (- sy ey)) (osm--update)))) (setq track-mouse 'dragging) - (set-transient-map map t (lambda () (setq track-mouse nil))))) + (set-transient-map map + (lambda () (eq (car-safe last-input-event) 'mouse-movement)) + (lambda () (setq track-mouse nil))))) (defun osm-zoom-click (event) "Zoom to the location of the click EVENT."