Mouse clicks, mouse movements and function keys no longer appear in the input stream as characters; instead, other kinds of Lisp objects represent them as input.
event-modifiers
(see below).
f1
in the input stream.
There are a few exceptions to the symbol naming convention:
kp-add
, kp-decimal
, kp-divide
, ...
kp-0
, kp-1
, ...
kp-f1
, kp-f2
, kp-f3
, kp-f4
left
, up
, right
, down
(button-symbol (window (column . row) buffer-pos timestamp))Here is what the elements normally mean:
mouse-1
, mouse-2
, ..., where the buttons are normally
numbered left to right.
You can also use prefixes `A-', `C-', `H-', `M-',
`S-' and `s-' for modifiers alt, control, hyper, meta, shift
and super, just as you would with function keys.
(0 . 0)
.
vertical-scroll-bar
, and the pair (column
. row)
is replaced with a pair (portion
. whole)
, where portion is the distance of the click from
the top or left end of the scroll bar, and whole is the length of
the entire scroll bar.
If the position is on a mode line or the vertical line separating
window from its neighbor to the right, then buffer-pos is
the symbol mode-line
or vertical-line
. In this case
row and column do not have meaningful data.
(button-symbol (window1 (column1 . row1) buffer-pos1 timestamp1) (window2 (column2 . row2) buffer-pos2 timestamp2))The name of button-symbol contains the prefix `drag-'. The second and third elements of the event give the starting and ending position of the drag. The `drag-' prefix follows the modifier key prefixes such as `C-' and `M-'. If
read-key-sequence
receives a drag event which has no key
binding, and the corresponding click event does have a binding, it
changes the drag event into a click event at the drag's starting
position. This means that you don't have to distinguish between click
and drag events unless you want to.
read-key-sequence
, and the Emacs command loop,
ignore any down events that don't have command bindings. This means
that you need not worry about defining down events unless you want them
to do something. The usual reason to define a down event is so that you
can track mouse motion until the button is released.
(down-mouse-1 (#<window 18 on NEWS> 2613 (0 . 38) -864320)) (mouse-1 (#<window 18 on NEWS> 2613 (0 . 38) -864180))Or, while holding the control key down, the user might hold down the second mouse button, and drag the mouse from one line to the next. That produces two events, as shown here:
(C-down-mouse-2 (#<window 18 on NEWS> 3440 (0 . 27) -731219)) (C-drag-mouse-2 (#<window 18 on NEWS> 3440 (0 . 27) -731219) (#<window 18 on NEWS> 3510 (0 . 28) -729648))Or, while holding down the meta and shift keys, the user might press the second mouse button on the window's mode line, and then drag the mouse into another window. That produces an event like this:
(M-S-down-mouse-2 (#<window 18 on NEWS> mode-line (33 . 31) -457844)) (M-S-drag-mouse-2 (#<window 18 on NEWS> mode-line (33 . 31) -457844) (#<window 20 on carlton-sanskrit.tex> 161 (33 . 3) -453816))
track-mouse
form, moving the mouse generates events
that look like this:
(mouse-movement (window (column . row) buffer-pos timestamp))The second element of the list describes the current position of the mouse, just as in a mouse click event. Outside of
track-mouse
forms, Emacs does not generate events for
mere motion of the mouse, and these events do not appear.
(switch-frame new-frame)where new-frame is the frame switched to. In X windows, most window managers are set up so that just moving the mouse into a window is enough to set the focus there. As far as the user is concerned, Emacs behaves consistently with this. However, there is no need for the Lisp program to know about the focus change until some other kind of input arrives. So Emacs generates the focus event only when the user actually types a keyboard key or presses a mouse button in the new frame; just moving the mouse between frames does not generate a focus event. The global key map usually binds this event to the
internal-select-frame
function, so that characters typed at a
frame apply to that frame's selected window.
If the user switches frames in the middle of a key sequence, then Emacs
delays the switch-frame
event until the key sequence is over.
For example, suppose C-c C-a is a key sequence in the current
buffer's keymaps. If the user types C-c, moves the mouse to
another frame, and then types C-a, read-key-sequence
returns the sequence "\C-c\C-a"
, and the next call to
read-event
or read-key-sequence
will return the
switch-frame
event.