All Manuals > CAPI User Guide and Reference Manual > 21 CAPI Reference Entries

NextPrevUpTopContentsIndex

scroll-bar

Class
Summary

A pane which displays a scroll bar.

Package

capi

Superclasses

range-pane
simple-pane
titled-object

Initargs

:line-size

The distance scrolled by the scroll-line gesture.

:page-size

The distance scrolled by clicking inside the scroll bar.

:callback

A function called after a scroll gesture, or nil.

Accessors

scroll-bar-line-size
scroll-bar-page-size

Description

The class scroll-bar implements panes which display a scroll bar and call a callback when the user scrolls. It is not however the most usual way to add scroll bars - see the note below about simple-pane.

line-size is the logical size of a line, and is the distance moved when the user enters a scroll-line gesture, that is clicking on one of the arrow buttons at either end of the scroll bar or using a suitable arrow key. The default value of line-size is 1.

page-size is the logical size of a page, and is the distance moved when the user clicks inside the scroll bar. The default value of page-size is 10.

callback can be nil, meaning there is no callback. This is the default value. Otherwise, is a function of four arguments, the interface containing the scroll-bar, the scroll-bar itself, the mode of scrolling and the amount of scrolling. It has this signature:

callback interface scroll-bar how where

how can be one of :line, :page, :move, or :drag.

If how is :line, then where is an integer indicating how many lines were scrolled.

If how is :page, then where is an integer indicating how many pages were scrolled.

If how is :move or :drag, then where is an integer giving the new location of the slug-start , or :start or :end.

Notes
  1. The location of the slug can be found by the range-pane accessor range-slug-start.
  2. Rather than using scroll-bar, it is more usual to add scroll bars to a pane by the simple-pane initargs :horizontal-scroll and :vertical-scroll
Example
(defun sb-callback (interface sb how where)
  (declare (ignorable interface))
  (format t "Scrolled ~a where ~a : ~a~%"
          how where (range-slug-start sb)))
 
(contain 
 (make-instance 'capi:scroll-bar
                :callback 'sb-callback
                :page-size 10
                :line-size 2
                :visible-min-width 200))
See also

simple-pane
Slider, Progress bar and Scroll bar


CAPI User Guide and Reference Manual (Unix version) - 3 Aug 2017

NextPrevUpTopContentsIndex