abo-abo / hydra

make Emacs bindings that stick around
1.84k stars 112 forks source link

how to keep the hydra open whilst scrolling the mouse #390

Open zcaudate opened 3 years ago

zcaudate commented 3 years ago

I wanted to be able to keep the hydra open whilst moving around in the buffer so have defined the movement keys to the hydra. However, I'm not sure what to do with mouse keys.

I'd like to have mouse clicks and scrolling available so that browsing the buffer with the mouse is possible without affecting the hydra. How can i bind those keys to the hydra?

(defhydra+ e/menu-fn::git-menu ()
  ("<prior>" scroll-up-command)
  ("<next>" scroll-down-command)
  ("<up>" previous-line)
  ("<left>" left-char)
  ("<right>" right-char)
  ("<down>" next-line)
  ("C-<up>" previous-paragraph)
  ("C-<down>" next-paragraph)
  ;;(down-mouse-1 mouse-drag-region)
  ("<wheel-up>" e/scroll-down-one)
  ("<wheel-down>" e/scroll-up-one))
zcaudate commented 3 years ago

okay... now I feel kind of stupid. In this case, setting :exit nil :foreign-keys run to the hydra solves it.

zcaudate commented 3 years ago

Actually, the :foreign-keys run setting works for all keys. I was hoping to restrict it to just the arrows and the mouse.

bestlem commented 2 years ago

A way might be to add those mouse keys to hydra-base-map before defining any hydrae

zcaudate commented 2 years ago

@bestlem have you tried? does it work?