[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: menu-item-actions
- To: djskrien@COLBY.EDU (Dale Skrien)
- Subject: Re: menu-item-actions
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Mon, 16 Mar 1992 20:18:15 -0500
- Cc: info-mcl
> Dialog-item-actions take a single parameter: the dialog item
>itself. However, menu-item-actions don't take any parameters. Why is
>that?
Largely because I neglected to notice that it would make sense to
have the two be similar when I converted the code from Object Lisp.
>I would like to refer to a menu-item from within its
>menu-item-action. Is there an easy way to do that?
You can use closures as Straz suggested, or the following:
(defclass arg-menu-item (menu-item) ())
(defmethod menu-item-action ((item arg-menu-item))
(let ((f (menu-item-action-function item)))
(when f (funcall f item))))
A test case:
(add-menu-items *tools-menu*
(make-instance 'arg-menu-item
:menu-item-title "Print me"
:menu-item-action 'print))