CLIM mail archive

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

Thanks...and More Questions About Command Tables



    Date: Wed, 20 Nov 1991 13:19 EST
    From: Joe Sherman <joebob@cs.washington.edu>

    Thanks to all who replied to my questions about hiding commands.  I have
    code working now to switch between a hierarchy of command tables.  Now I have
    a follow-up question concerning the inheritance.

    I have the following hierarchy of command tables:

    "e3-index" (root): contains commands "e3-quit" and "e3-select"

    "e3-article" (inherits from e3-index): contains "e3-select-part", "e3-render",
						    "e3-home"

    "e3-leaf" (inherits from e3-article): contains "e3-kill"

    I use clim:define-command to place a command in one of these command tables.

    When I switch to table "e3-article", I expect the menu to contain the
    inherited command "e3-quit".  This does not happen.

Menu items are not inherited from parent command tables.  I am dismayed to
see that this is not documented.

Historical note: CLIM behaves the way it does w.r.t command menu items
because some of the CLIM 1.0 designers (at least Dave Moon and myself)
thought that inheritance of command menu items is more often wrong than
right.  I still think this design decision is the correct one, but enough
evidence to the contrary could change my mind.

    Is there a way for inherited (menu) commands to be included on the menus of
    descendent command tables?  Do I need to use the :MENU keyword of
    CLIM:DEFINE-COMMAND-TABLE?  (I'm also using the :AFTER :SORT keywords
    in CLIM:DEFINE-COMMAND...)

You should just use the :MENU keyword to CLIM:DEFINE-COMMAND-TABLE to
establish the menu for the child command tables.  Note that command tables
are lightweight objects, so the seemingly wasteful use of a "whole command
table just to hold the menu" is not really wasteful at all.

    Here's the relevant code if you're interested:

Oh, by the way, if you add the :GESTURE option to these two command
definitions...

    (define-command (e3-select :command-table e3-index)
	((article 'e3-article :GESTURE :SELECT))
      (with-slots (selected-article selected-part) *application-frame*
		  (setf selected-article article)
		  (setf selected-part selected-article)
		  (setf (frame-command-table *application-frame*)
			(find-command-table 'e3-article))
		  (set-frame-layout *application-frame* 'e3-article-layout)))

    (define-command (e3-select-part :command-table e3-article)
	((part 'e3-part :GESTURE :SELECT))
      (with-slots (selected-part) *application-frame*
		  (setq selected-part part)))

...then DEFINE-COMMAND will write these two translators for you, and
you won't need to do it explicitly yourself.

    (define-presentation-to-command-translator e3-select-icon
	(e3-article e3-select e3-index)
      (object)
      `(,object))

    (define-presentation-to-command-translator e3-select-schema
	(e3-part e3-select-part e3-article)
      (object)
      `(,object))

0,,

Follow-Ups: References:

Main Index | Thread Index