[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: more on mouse to command presentation
Date: Wed, 11 Jul 90 17:24:52 MDT
From: drstrip@cs.sandia.gov (David R Strip [1411])
I guess I wasn't specific enough.
I would like to present a pretty something to stand in for a
form to be evaluated in the listener.
While (present 'form 'sys:form) works, you get the form itself
as the mouseable object.
What I would like is something like
(dw:with-output-as-presentation (:object 'form :type 'sys:form)
(print "Pretty Name of Form"))
and have the mouse action on Pretty ... cause the form to eval.
This does not seem to work.
Strip
Caveat: I'm sure others have written more presentation code, but here's some
help anyway.
You need to define a type using define-presentation-type writing a :printer
and a :parser for it. The printer presents the object as you like, the
parser must be able to read the object (or objects you'd like it to match)
and convert them to the correct output type. You can then use presentation
translators to make your new type acceptable when the listener is looking
for a form to input.
Here's a quick and dirty example.
e.g.
(define-presentation-type pretty-form1 ()
:parser ((stream)
(accept 'sys:form :stream stream))
:printer ((object stream)
(format stream "~A" (string-downcase (string object)))))
(present 'TEST-ATOM 'pretty-form1)
(accept 'pretty-form1)
this shows we can mouse on the object. Now all you have to do is something
like
(define-presentation-translator eval-me (pretty-form1 sys:form)
(form1)
(eval form1))
(setq mumble 213)
(present 'mumble 'pretty-form1)
if you notice, from the listener, mouse-l of the presentation mumble is
documented as 213 - the result of the eval.
----
Brad Miller U. Rochester Comp Sci Dept.
miller@cs.rochester.edu {...allegra!rochester!miller}