summaryrefslogtreecommitdiff
path: root/devdocs/elisp/accessing-scroll.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/accessing-scroll.html')
-rw-r--r--devdocs/elisp/accessing-scroll.html17
1 files changed, 17 insertions, 0 deletions
diff --git a/devdocs/elisp/accessing-scroll.html b/devdocs/elisp/accessing-scroll.html
new file mode 100644
index 00000000..03550d55
--- /dev/null
+++ b/devdocs/elisp/accessing-scroll.html
@@ -0,0 +1,17 @@
+ <h4 class="subsection">Accessing Scroll Bar Events</h4> <p>These functions are useful for decoding scroll bar events. </p> <dl> <dt id="scroll-bar-event-ratio">Function: <strong>scroll-bar-event-ratio</strong> <em>event</em>
+</dt> <dd><p>This function returns the fractional vertical position of a scroll bar event within the scroll bar. The value is a cons cell <code>(<var>portion</var> . <var>whole</var>)</code> containing two integers whose ratio is the fractional position. </p></dd>
+</dl> <dl> <dt id="scroll-bar-scale">Function: <strong>scroll-bar-scale</strong> <em>ratio total</em>
+</dt> <dd>
+<p>This function multiplies (in effect) <var>ratio</var> by <var>total</var>, rounding the result to an integer. The argument <var>ratio</var> is not a number, but rather a pair <code>(<var>num</var> . <var>denom</var>)</code>—typically a value returned by <code>scroll-bar-event-ratio</code>. </p> <p>This function is handy for scaling a position on a scroll bar into a buffer position. Here’s how to do that: </p> <div class="example"> <pre class="example">(+ (point-min)
+ (scroll-bar-scale
+ (posn-x-y (event-start event))
+ (- (point-max) (point-min))))
+</pre>
+</div> <p>Recall that scroll bar events have two integers forming a ratio, in place of a pair of x and y coordinates. </p>
+</dd>
+</dl><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/Accessing-Scroll.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Accessing-Scroll.html</a>
+ </p>
+</div>