home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / oodleutl.cpt / oodles-of-utils / mixin-madness / dialog-item-mixins / double-click-dim.lisp < prev    next >
Encoding:
Text File  |  1992-01-30  |  2.1 KB  |  56 lines

  1. (in-package :oou)
  2. (oou-provide :double-click-dim)
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4. ;; double-click-dim.Lisp
  5. ;;
  6. ;; Copyright ⌐ 1992 Northwestern University Institute for the Learning Sciences
  7. ;; All Rights Reserved
  8. ;;
  9. ;; author: Michael S. Engber
  10. ;;
  11. ;; Dialog item mixin for handling double-clicks
  12. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13.  
  14. (export '(double-click-dim dialog-item-double-click-action))
  15.  
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17.  
  18. (defclass double-click-dim ()
  19.   ((dialog-item-double-click-action-funtion :initarg :dialog-item-double-click-action)))
  20.  
  21. (defmethod dialog-item-double-click-action ((di double-click-dim))
  22.   (when (slot-boundp di 'dialog-item-double-click-action-funtion)
  23.     (funcall (slot-value di 'dialog-item-double-click-action-funtion) di)))
  24.  
  25.   (defmethod view-click-event-handler :around ((di double-click-dim) where)
  26.     (declare (ignore where))
  27.     (if (double-click-p)
  28.       (dialog-item-double-click-action di)
  29.       (call-next-method)))
  30.  
  31. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  32.  
  33. #|
  34.  
  35. ;;; a modest example - adding button behavior to static text dialog items
  36.  
  37. (defclass dcbut (button-dialog-item double-click-dim) ())
  38.  
  39. (setf *test-w*
  40.       (make-instance 'dialog
  41.                      :window-type :document
  42.                      :view-position :centered
  43.                      :view-size #@(200 100)
  44.                      :window-title "rect-button-dim demo"
  45.                      :close-box-p t
  46.                      :view-subviews
  47.                      (list (make-dialog-item 'dcbut
  48.                                              #@(20 20)
  49.                                              #@(160 18)
  50.                                              "I'm static text + a mixin"
  51.                                              #'(lambda (item) (declare (ignore item)) (ed-beep))
  52.                                              :dialog-item-double-click-action
  53.                                              #'(lambda (item) (declare (ignore item)) (eval-enqueue '(print "hi,ho")))
  54.                                              ))))
  55.  
  56. |#