home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / lisp / mcl / 1281 < prev    next >
Encoding:
Text File  |  1992-08-20  |  4.3 KB  |  105 lines

  1. Path: sparky!uunet!paladin.american.edu!europa.asd.contel.com!darwin.sura.net!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!data.nas.nasa.gov!taligent!apple!cambridge.apple.com!bill@cambridge.apple.com
  2. From: bill@cambridge.apple.com (Bill St. Clair)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: Re: cell-select in sequence-dialog-items
  5. Message-ID: <9208202000.AA17160@cambridge.apple.com>
  6. Date: 20 Aug 92 21:05:38 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 91
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10. Full-Name: Bill St. Clair
  11. Original-To: owens@jonquil.uchicago.edu (Christopher Owens)
  12. Original-Cc: info-mcl
  13.  
  14. >I'm noticing that, contrary to my intuitive expectations,
  15. >sequence-dialog-items in MCL 2.0 do not call CELL-SELECT when the user
  16. >selects a cell by clicking on it.  Cells become highlighted and added
  17. >to the list returned by SELECTED-CELLS, but the CELL-SELECT method
  18. >itself does not appear to be called.
  19. >
  20. >I had hoped to specialize an :after method for this generic function
  21. >(and for cell-deselect) on a subclass of sequence-dialog-item that
  22. >would accomplish the behavior of activating a few buttons when and
  23. >only when one or more items in a table were selected.  It seems like
  24. >CELL-SELECT and CELL-DESELECT are a more logical place to put this
  25. >behavior than on VIEW-CLICK-EVENT-HANDLER, since sometimes cells might
  26. >be selected or deselected other than by clicking. (i.e. by typing
  27. >characters as in the select file dialog, or by program action)
  28.  
  29. Sorry for not answering you the first time.
  30.  
  31. This is not as easy as you think. The VIEW-CLICK-EVENT-HANDLER method
  32. for TABLE-DIALOG-ITEM calls #_LClick which tracks the mouse, taking into
  33. consideration the states of the shift and command keys (depending on
  34. the :SELECTION-TYPE). When the user releases the mouse button, #_LClick
  35. returns, possibly having changed the selection state of some of the
  36. cells. Since most people do not share your desire to have CELL-SELECT
  37. and CELL-DESELECT called at this time (which would redo what has
  38. already been done by the ROM), MCL doesn't bother to record which
  39. cells were selected before #_LClick, compare it with which cells are
  40. selected after #_LClick, and make appropriate calls to CELL-SELECT
  41. and CELL-DESELECT.
  42.  
  43. It seems to me that you can easily do the following:
  44.  
  45. (defclass my-sequence-dialog-item (sequence-dialog-item) 
  46.   ((action-buttons :initarg :action-buttons :accessor action-buttons)))
  47.  
  48. (defmethod view-click-event-handler :after ((d my-sequence-dialog-item) where)
  49.   (declare (ignore where))
  50.   (fixup-buttons d))
  51.  
  52. (defmethod cell-deselect :after ((d my-sequence-dialog-item) h &optional v)
  53.   (declare (ignore h v))
  54.   (fixup-buttons d))
  55.  
  56. (defmethod cell-select :after ((d my-sequence-dialog-item) h &optional v)
  57.   (declare (ignore h v))
  58.   (fixup-buttons d))
  59.  
  60. ; This is so we can prevent flashing when arrow keys are typed
  61. ; to an arrow dialog.
  62. (defvar *ignore-fixup* nil)
  63.  
  64. (defmethod fixup-buttons ((d my-sequence-dialog-item))
  65.   (unless (eq *ignore-fixup* d)
  66.     (let ((buttons (action-buttons d))
  67.           (enabler (if (selected-cells d)
  68.                      'dialog-item-enable
  69.                      'dialog-item-disable)))
  70.       (dolist (button buttons)
  71.         (funcall enabler button)))))
  72.  
  73. ; a ccl::arrow-dialog moves the selection in its first sequence-dialog-item
  74. ; when an arrow key is typed.
  75. (defclass my-arrow-dialog (ccl::arrow-dialog) ())
  76.  
  77. (defmethod view-key-event-handler ((d my-arrow-dialog) key)
  78.   (declare (ignore key))
  79.     (let* ((table (view-named :table d))
  80.            (*ignore-fixup* table))
  81.       (prog1 (call-next-method)
  82.         (when table (fixup-buttons table)))))
  83.  
  84. (defun test-dialog ()
  85.   (let* ((d (make-instance 'my-arrow-dialog
  86.               :view-size #@(160 200)
  87.               :window-show nil))
  88.          (button (make-instance 'button-dialog-item
  89.                    :dialog-item-text "Do something"
  90.                    :view-position #@(10 160)
  91.                    :view-container d))
  92.          (table (make-instance 'my-sequence-dialog-item
  93.                   :table-sequence '(one two three four five six seven eight nine ten)
  94.                   :view-position #@(10 10)
  95.                   :view-size #@(140 130)
  96.                   :view-container d
  97.                   :view-nick-name :table
  98.                   :action-buttons (list button))))
  99.     (fixup-buttons table)
  100.     (window-show d)))
  101.  
  102. #|
  103. (test-dialog)
  104. |#
  105.