Common Lisp Interface Manager 2.0 User's Guide > Chapter 12 Menus and Dialogs > 12.4 Examples of Menus and Dialogs in CLIM

NextPrevUpTopContentsIndex

12.4.6 Using menu-choose-from-drawer

This example displays in the window *page-stream* the choices One through Ten in boldface type. When the user selects one, the string is returned along with the gesture that selected it.

(clim:menu-choose-from-drawer 
 *page-stream* 'string 
 #'(lambda (stream type) 
     (clim:with-text-face (:bold stream)    
                          (dotimes (count 10)        
                            (clim:present (string-capitalize 
                                           (format nil "~R" (1+ count)))
                                          type :stream stream)        
                            (terpri stream))))) 

This example shows how you can use menu-choose-from-drawer with with-menu to create a temporary menu:

(defun choose-compass-direction (parent-window) 
  (labels
      ((draw-compass-point
        (stream ptype symbol x y) 
        (clim:with-output-as-presentation 
         (:stream stream :object symbol :type ptype) 
         (clim:draw-string* stream
                            (symbol-name symbol) x y 
                            :align-x :center 
                            :align-y :center 
                            :text-style 
                            '(:sans-serif :roman :large)))) 
       (draw-compass
        (stream ptype) 
        (clim:draw-line* stream 0 25 0 -25 :line-thickness 2) 
        (clim:draw-line* stream 25 0 -25 0 :line-thickness 2) 
        (loop for point in '((n 0 -30) (s 0 30) (e 30 0)(w -30 0))
              do (apply #'draw-compass-point 
                        stream ptype point))))
    (clim:with-menu (menu parent-window) 
                    (clim:menu-choose-from-drawer menu 'clim:menu-item
                                                  #'draw-compass))))

Common Lisp Interface Manager 2.0 User's Guide - 22 Dec 2009

NextPrevUpTopContentsIndex