[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: y-or-n-dialog



I'm sure that other's have contributed similar code, but here is 
a little routine that I have put into my "Init.lisp" file, so I
can use a more "standard" OK/Cancel dialog in my programs.  It
returns "t" or "nil" depending on the button you click, and you
can override the key's text with the :cancel-text and :ok-text 
parameters.
   Hope it's useful
        Jeffrey

(defun OK-Cancel-Dialog (message &key (OK-text "OK")
                                 (cancel-text "Cancel")
                                 (size #@(300 100)))
;; 1992, Jeffrey Kane, MD   KBS
  (modal-dialog (make-instance 'dialog
    :WINDOW-TYPE
    :DOUBLE-EDGE-BOX
    :WINDOW-TITLE
    "OK-Cancel-Dialog"
    :VIEW-POSITION
    '(:TOP 60)
    :VIEW-SIZE
    size
    :CLOSE-BOX-P
    nil
    :VIEW-FONT
    '("Chicago" 12 :SRCOR :PLAIN)
    :VIEW-SUBVIEWS
    (LIST (MAKE-DIALOG-ITEM
           'STATIC-TEXT-DIALOG-ITEM
           #@(20 20)
           (make-point (- (point-h size) 20) (- (point-v size) 67))
           message
           'NIL)
          (MAKE-DIALOG-ITEM 'BUTTON-DIALOG-ITEM
           (make-point (- (point-h size) 77) (- (point-v size) 34))
           #@(62 16)
           Cancel-Text
           #'(LAMBDA (ITEM) (return-from-modal-dialog nil))
           :DEFAULT-BUTTON
           t)
          (MAKE-DIALOG-ITEM
           'BUTTON-DIALOG-ITEM
           (make-point (- (point-h size) 153) (- (point-v size) 33))
           #@(62 16)
           OK-text
           #'(LAMBDA (ITEM) item (return-from-modal-dialog t))
           :DEFAULT-BUTTON
           NIL)))))