CLIM mail archive

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

presentation action



    Date: Fri, 30 Oct 1992 14:38 EST
    From: Brian Anderson <bha@atc.boeing.com>

    Allegro CL 4.1
    CLIM 1.1
    SunOs 4.1.1

    I have a presentation action that I *don't* want applicable in certain
    input contexts (clim:command-arguments).  I am trying to write a
    tester function to restrict the applicability of this presentation
    action but am having problems with (I think) nested input contexts.

    I am accepting a command line argument.  When I move the mouse over a
    presentation (of type essential-node), the input context as seen by
    the tester function is first clim:command-arguments and then
    essential-node.  How do I write a tester that looks in the nested set
    of input contexts to determine if we are really trying to accept a
    command line argument.  Why do I see the presentation type of the
    thing I wave the mouse over as an input context?

    Here is my presentation action.

    (clim:define-presentation-action node-operation-menu
	(essential-node nil graph-browser-command-table
	 :documentation
	   ((object stream)
	    (clim:with-text-face (:bold stream)
	      (format stream "Node Operations for ~s" (node-pretty-name object))))
	 :tester
	   ((context-type)
	    ;; When accepting command arguments, disable this.
	    (not (clim:presentation-subtypep 'clim:command-arguments context-type)))
	 :gesture :menu)
	(presentation frame window x y)
      (clim:call-presentation-menu presentation clim:*input-context*
				   frame window x y
				   :for-menu t
				   :label "Node Operations"))

Note that *INPUT-CONTEXT* is not the same as the CONTEXT-TYPE argument.
*INPUT-CONTEXT* is an object that reflects the entire, nested input
context, whereas CONTEXT-TYPE is just a presentation type that reflects
the single "piece of" input context on which the translator (or tester)
was called.  So, what you really want to do in your tester is something
like this:

  (dolist (this-context clim:*input-context* t)
    (let ((context-type (clim::input-context-type this-context)))
      (when (clim:presentation-subtypep 'clim:command-arguments context-type)
        ;; If any part of the input context is looking for a command
	;; argument, the tester will fail
	(return nil))))))

I didn't actually test this, by the way, so complain if it doesn't work.

    Note that this is derived from the example on pg. 198.  Note also that
    the example uses the :tester-definitive option which (for my version
    of CLIM) will not compile.  It tells me that :tester-definitive is not
    a valid option.

:TESTER-DEFINITIVE must always be T for presentation actions, so CLIM
does not provide the rope for you to hang yourself with :-).

0,,

References:

Main Index | Thread Index