Alexander-Miller / treemacs

GNU General Public License v3.0
2.12k stars 155 forks source link

Is there a way to disable drag-n-drop in treemacs? #1008

Closed zoechi closed 1 year ago

zoechi commented 1 year ago

I often use the mouse to navigate (scroll, expand/collaps folders, ...) and often when I click the treemacs window scrolls a bit or I accidentally move the mouse a bit, suddenly files or folders are moved. Restoring that is quite cumbersome.

I never use the mouse to move files or folders intentionally and it would be great if I could just disable drag-n-drop.

ignamartinoli commented 1 year ago

I'm having the same problem!

ignamartinoli commented 1 year ago

@zoechi I just found the solution

(use-package treemacs
  :bind
  (:map global-map
        ([f2] . treemacs)
   :map treemacs-mode-map       ;; THE SOLUTION
        ([drag-mouse-1] . nil)) ;; IS RIGHT HERE
  :init (setq treemacs-show-hidden-files nil))
zoechi commented 1 year ago

@ignamartinoli thanks a lot🚀. I guess this can be closed then.

Alexander-Miller commented 1 year ago

@zoechi I just found the solution

This is the correct approach. That or overriding the behavior of treemacs-dragleftclick-action with fset or advice.