3.2 Mouse cursor objects

3.2.1 Making mouse cursor objects

To see an example of a mouse cursor object, first create a new bitmap and draw a circle and a line on it:

(setq *mouse-bitmap*
      (make-bitmap :height (min 15 maximum-cursor-height)
                   :width (min 15 maximum-cursor-width)
                   :depth 1))

(draw-line *mouse-bitmap* (make-position 0 0) (make-position maximum-cursor-width maximum-cursor-height) :width 2)

(draw-circle *mouse-bitmap* (make-position (/ maximum-cursor-width 2) (/ maximum-cursor-height 2)) 5 :width 2)

Next, use the function make-mouse-cursor to make a mouse cursor object whose image is the new cursor's bitmap:

(setq *mouse-cursor* (make-mouse-cursor *mouse-bitmap*))
The functioncurrent-mouse-cursor returns the current mouse cursor object. In the next example the current mouse cursor is saved and then changed to the new mouse cursor.

(setf *old-mouse-cursor* (current-mouse-cursor))
(setf (current-mouse-cursor) *mouse-cursor*)
Move the mouse cursor onto the root viewport. You see that the mouse cursor object appears as a line drawn through a circle, which is the design you drew on*mouse-bitmap*.

To restore the original appearance of the mouse cursor, bind the current mouse cursor to the value of*old-mouse-cursor*:

(setf (current-mouse-cursor) *old-mouse-cursor*)
The mouse cursor's hot spot is the exact location that the mouse is pointing to at any moment. To specify the mouse cursor's hot spot when invoking the function make-mouse-cursor, use the keyword arguments:x-offset and:y-offset; the value of these arguments is 0 by default.

The Window Tool Kit - 9 SEP 1996

Generated with Harlequin WebMaker