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

Re: menu-item-actions



>        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))