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

Re: menu-item-actions



Dale J. Skrien  writes:
	Dialog-item-actions take a single parameter: the dialog item
	itself.  However, menu-item-actions don't take any parameters.  Why is
	that?  I would like to refer to a menu-item from within its
	menu-item-action.  Is there an easy way to do that?


Here is a plug for my menu-enhancements package. The package
supports window-menu-items that have the functionality that
you want, allowing you to say
 (make-instance
   'window-menu-item
   :menu-item-title "fred"
   :menu-item-action #'(lambda (item) item ....))
 where item is bound to the menu-item
       the containing-view function can extract the view that
             contains the menu-item.

You could also consider using the following code in
the standard system:
   (setq fred (make-instance 'menu-item :menu-item-title "Fred"))
   (setf (menu-item-action-function fred)
	 #'(lambda ()
	      (print (menu-item-title fred))))

The real problem with Macintosh menus is that they understand
a parameter free environment (menu-item) and a window environment
(window-menu-item) but they don't understand views, dialog items etc.
This forces you to go through a convoluted sequence when you want
to operate on a selected item.