emacs-devel
[Top][All Lists]
Advanced

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

Re: Disabling mouse input


From: James Cherti
Subject: Re: Disabling mouse input
Date: Sun, 3 Nov 2024 09:01:08 -0500
User-agent: Mozilla Thunderbird

Hello Stefan,

Just in case anyone is interested:

I have created a small Emacs package inspired by your idea of using
input-decode-map to disable the mouse:
https://github.com/jamescherti/inhibit-mouse.el

--
James Cherti
https://www.jamescherti.com/

On 2024-11-02 09:38, Stefan Monnier wrote:
(This should not surprise anyone, because input events are handled in
C, not in Lisp, and so disabling this in Lisp is expected to be
impossible.)
Well, everyone I talked to was sure it must be possible in
Lisp, so I figured somebody would ask eventually.
My first intuition would be to do something like:

     (define-key input-decode-map [wheel-down] (lambda (_prompt) []))
     (define-key input-decode-map [wheel-up]   (lambda (_prompt) []))
     (define-key input-decode-map [mouse-1]    (lambda (_prompt) []))
     (define-key input-decode-map [mouse-2]    (lambda (_prompt) []))
     (define-key input-decode-map [mouse-3]    (lambda (_prompt) []))

If that works, then you'll probably want to add more bindings for those
cases where you hit the "mouse" while holding a modifier, i.e. something like:

     (dolist (modifier '(control meta nil))
       (dolist (base '(wheel-down wheel-up mouse-1 mouse-2 mouse-3))
         (define-key input-decode-map
                     (vector (event-convert-list (list modifier base)))
                     (lambda (_prompt) []))))
- Stefan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]