diff options
Diffstat (limited to 'devdocs/elisp/classifying-events.html')
| -rw-r--r-- | devdocs/elisp/classifying-events.html | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/devdocs/elisp/classifying-events.html b/devdocs/elisp/classifying-events.html new file mode 100644 index 00000000..a15dcce2 --- /dev/null +++ b/devdocs/elisp/classifying-events.html @@ -0,0 +1,63 @@ + <h4 class="subsection">Classifying Events</h4> <p>Every event has an <em>event type</em>, which classifies the event for key binding purposes. For a keyboard event, the event type equals the event value; thus, the event type for a character is the character, and the event type for a function key symbol is the symbol itself. For events that are lists, the event type is the symbol in the <small>CAR</small> of the list. Thus, the event type is always a symbol or a character. </p> <p>Two events of the same type are equivalent where key bindings are concerned; thus, they always run the same command. That does not necessarily mean they do the same things, however, as some commands look at the whole event to decide what to do. For example, some commands use the location of a mouse event to decide where in the buffer to act. </p> <p>Sometimes broader classifications of events are useful. For example, you might want to ask whether an event involved the <tt class="key">META</tt> key, regardless of which other key or mouse button was used. </p> <p>The functions <code>event-modifiers</code> and <code>event-basic-type</code> are provided to get such information conveniently. </p> <dl> <dt id="event-modifiers">Function: <strong>event-modifiers</strong> <em>event</em> +</dt> <dd> +<p>This function returns a list of the modifiers that <var>event</var> has. The modifiers are symbols; they include <code>shift</code>, <code>control</code>, <code>meta</code>, <code>alt</code>, <code>hyper</code> and <code>super</code>. In addition, the modifiers list of a mouse event symbol always contains one of <code>click</code>, <code>drag</code>, and <code>down</code>. For double or triple events, it also contains <code>double</code> or <code>triple</code>. </p> <p>The argument <var>event</var> may be an entire event object, or just an event type. If <var>event</var> is a symbol that has never been used in an event that has been read as input in the current Emacs session, then <code>event-modifiers</code> can return <code>nil</code>, even when <var>event</var> actually has modifiers. </p> <p>Here are some examples: </p> <div class="example"> <pre class="example">(event-modifiers ?a) + ⇒ nil +(event-modifiers ?A) + ⇒ (shift) +(event-modifiers ?\C-a) + ⇒ (control) +(event-modifiers ?\C-%) + ⇒ (control) +(event-modifiers ?\C-\S-a) + ⇒ (control shift) +(event-modifiers 'f5) + ⇒ nil +(event-modifiers 's-f5) + ⇒ (super) +(event-modifiers 'M-S-f5) + ⇒ (meta shift) +(event-modifiers 'mouse-1) + ⇒ (click) +(event-modifiers 'down-mouse-1) + ⇒ (down) +</pre> +</div> <p>The modifiers list for a click event explicitly contains <code>click</code>, but the event symbol name itself does not contain ‘<samp>click</samp>’. Similarly, the modifiers list for an <acronym>ASCII</acronym> control character, such as ‘<samp>C-a</samp>’, contains <code>control</code>, even though reading such an event via <code>read-char</code> will return the value 1 with the control modifier bit removed. </p> +</dd> +</dl> <dl> <dt id="event-basic-type">Function: <strong>event-basic-type</strong> <em>event</em> +</dt> <dd> +<p>This function returns the key or mouse button that <var>event</var> describes, with all modifiers removed. The <var>event</var> argument is as in <code>event-modifiers</code>. For example: </p> <div class="example"> <pre class="example">(event-basic-type ?a) + ⇒ 97 +(event-basic-type ?A) + ⇒ 97 +(event-basic-type ?\C-a) + ⇒ 97 +(event-basic-type ?\C-\S-a) + ⇒ 97 +(event-basic-type 'f5) + ⇒ f5 +(event-basic-type 's-f5) + ⇒ f5 +(event-basic-type 'M-S-f5) + ⇒ f5 +(event-basic-type 'down-mouse-1) + ⇒ mouse-1 +</pre> +</div> </dd> +</dl> <dl> <dt id="mouse-movement-p">Function: <strong>mouse-movement-p</strong> <em>object</em> +</dt> <dd><p>This function returns non-<code>nil</code> if <var>object</var> is a mouse movement event. See <a href="motion-events">Motion Events</a>. </p></dd> +</dl> <dl> <dt id="event-convert-list">Function: <strong>event-convert-list</strong> <em>list</em> +</dt> <dd> +<p>This function converts a list of modifier names and a basic event type to an event type which specifies all of them. The basic event type must be the last element of the list. For example, </p> <div class="example"> <pre class="example">(event-convert-list '(control ?a)) + ⇒ 1 +(event-convert-list '(control meta ?a)) + ⇒ -134217727 +(event-convert-list '(control super f1)) + ⇒ C-s-f1 +</pre> +</div> </dd> +</dl><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 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/Classifying-Events.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Classifying-Events.html</a> + </p> +</div> |
