[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: translating mouse clicks
From: |
rgb |
Subject: |
Re: translating mouse clicks |
Date: |
13 Jul 2005 17:46:53 -0700 |
User-agent: |
G2/0.2 |
> I have a trackball with four buttons which emacs sees as buttons
> mouse-1, mouse-3, mouse-4, and mouse-5. I would like emacs to
> treat mouse-4 clicks as though they were mouse-2 clicks.
>
> Googling finds suggestions to try
>
> (global-set-key [mouse-4] [mouse-2])
This essentially makes mouse-4 a keyboard macro which,
when executed, doesn't carry the proper associated events.
There are 2 things you can do with global-set-key.
(global-set-key [mouse-4] (lookup-key global-map [mouse-2]))
But you would need similar commands for shift, control,
meta, shift-control, shift-meta... versions of mouse-4.
And maybe down-mouse-4 ... as well depending on how many
variations of the key you wanted to remap.
A consequence of doing it this way is that it's static.
Once the global-set-key is done re-assignment of mouse-2
won't change what mouse-4 does.
The other way would be to write a function and map it to
all the mouse-4 events, like above. The function would
look up and called the mouse-2 event currently in effect.
> (define-key key-translation-map [mouse-4] [mouse-2])
> (keyboard-translate 'mouse-4 'mouse-2)
The doc seems to carefully exclude mentioning mouse events
concerning these methods (and function-key-map too). I
wouldn't expect them to help based on the doc I looked at.