CLIM mail archive


presentation actions

We were suprised to find that CLIM 0.9 did not have
define-presentation-action, so Jeff Morrill wrote one:

(defmacro define-action
	   (from-type to-type &key command-table gesture tester documentation (menu t))
	   &body body)
  ;; This is similar to define-presentation-translator, except that the body of the
  ;; action is not intended to return a value, but should instead side-effect some
  ;; sort of application state.
    (pushnew 'window arglist)
    (pushnew 'gesture arglist)
    ;; To prevent the body from getting evaluated in the process of testing the
    ;; applicability of the translator, the tester should return T as the second
    ;; value.
    (cond ((not tester)
	   (setq tester `((presentation) 
			  (values (ci::presentation-matches-type-p presentation ',from-type)
	  (t (setq tester `(,(first tester) (values (progn ,@(rest tester)) t)))))
    (when (and command-table (eql to-type 'command))
      (setq to-type `(command :command-table ,(eval command-table))))
       (,from-type ,to-type :tester ,tester :gesture ,gesture
	:menu ,menu
	:documentation ((stream) (format stream "~A" ,documentation)))
       (when (not (eq gesture :for-menu))
	 ;; pretty big hammer, but we need to get blips etc out of the input buffer.
	 (clim:stream-clear-input window)

Main Index | Thread Index