diff options
Diffstat (limited to 'devdocs/elisp/mouse-tracking.html')
| -rw-r--r-- | devdocs/elisp/mouse-tracking.html | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/devdocs/elisp/mouse-tracking.html b/devdocs/elisp/mouse-tracking.html new file mode 100644 index 00000000..55e8946c --- /dev/null +++ b/devdocs/elisp/mouse-tracking.html @@ -0,0 +1,10 @@ + <h3 class="section">Mouse Tracking</h3> <p>Sometimes it is useful to <em>track</em> the mouse, which means to display something to indicate where the mouse is and move the indicator as the mouse moves. For efficient mouse tracking, you need a way to wait until the mouse actually moves. </p> <p>The convenient way to track the mouse is to ask for events to represent mouse motion. Then you can wait for motion by waiting for an event. In addition, you can easily handle any other sorts of events that may occur. That is useful, because normally you don’t want to track the mouse forever—only until some other event, such as the release of a button. </p> <dl> <dt id="track-mouse">Macro: <strong>track-mouse</strong> <em>body…</em> +</dt> <dd> +<p>This macro executes <var>body</var>, with generation of mouse motion events enabled. Typically, <var>body</var> would use <code>read-event</code> to read the motion events and modify the display accordingly. See <a href="motion-events">Motion Events</a>, for the format of mouse motion events. </p> <p>The value of <code>track-mouse</code> is that of the last form in <var>body</var>. You should design <var>body</var> to return when it sees the up-event that indicates the release of the button, or whatever kind of event means it is time to stop tracking. </p> <p>The <code>track-mouse</code> form causes Emacs to generate mouse motion events by binding the variable <code>track-mouse</code> to a non-<code>nil</code> value. If that variable has the special value <code>dragging</code>, it additionally instructs the display engine to refrain from changing the shape of the mouse pointer. This is desirable in Lisp programs that require mouse dragging across large portions of Emacs display, which might otherwise cause the mouse pointer to change its shape according to the display portion it hovers on (see <a href="pointer-shape">Pointer Shape</a>). Therefore, Lisp programs that need the mouse pointer to retain its original shape during dragging should bind <code>track-mouse</code> to the value <code>dragging</code> at the beginning of their <var>body</var>. </p> +</dd> +</dl> <p>The usual purpose of tracking mouse motion is to indicate on the screen the consequences of pushing or releasing a button at the current position. </p> <p>In many cases, you can avoid the need to track the mouse by using the <code>mouse-face</code> text property (see <a href="special-properties">Special Properties</a>). That works at a much lower level and runs more smoothly than Lisp-level mouse tracking. </p><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/Mouse-Tracking.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Mouse-Tracking.html</a> + </p> +</div> |
