summaryrefslogtreecommitdiff
path: root/devdocs/elisp/event-examples.html
blob: 892103b073772ea69ff682b955110659b83a4ab3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 <h4 class="subsection">Event Examples</h4> <p>If the user presses and releases the left mouse button over the same location, that generates a sequence of events like this: </p> <div class="example"> <pre class="example">(down-mouse-1 (#&lt;window 18 on NEWS&gt; 2613 (0 . 38) -864320))
(mouse-1      (#&lt;window 18 on NEWS&gt; 2613 (0 . 38) -864180))
</pre>
</div> <p>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: </p> <div class="example"> <pre class="example">(C-down-mouse-2 (#&lt;window 18 on NEWS&gt; 3440 (0 . 27) -731219))
(C-drag-mouse-2 (#&lt;window 18 on NEWS&gt; 3440 (0 . 27) -731219)
                (#&lt;window 18 on NEWS&gt; 3510 (0 . 28) -729648))
</pre>
</div> <p>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 a pair of events like these: </p> <div class="example"> <pre class="example">(M-S-down-mouse-2 (#&lt;window 18 on NEWS&gt; mode-line (33 . 31) -457844))
(M-S-drag-mouse-2 (#&lt;window 18 on NEWS&gt; mode-line (33 . 31) -457844)
                  (#&lt;window 20 on carlton-sanskrit.tex&gt; 161 (33 . 3)
                   -453816))
</pre>
</div> <p>The frame with input focus might not take up the entire screen, and the user might move the mouse outside the scope of the frame. Inside the <code>track-mouse</code> special form, that produces an event like this: </p> <div class="example"> <pre class="example">(mouse-movement (#&lt;frame *ielm* 0x102849a30&gt; nil (563 . 205) 532301936))
</pre>
</div> <p>To handle a SIGUSR1 signal, define an interactive function, and bind it to the <code>signal usr1</code> event sequence: </p> <div class="example"> <pre class="example">(defun usr1-handler ()
  (interactive)
  (message "Got USR1 signal"))
(global-set-key [signal usr1] 'usr1-handler)
</pre>
</div><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
    <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Event-Examples.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Event-Examples.html</a>
  </p>
</div>