CLIM mail archive
[Prev][Next][Index][Thread]
More listener questions
Date: Mon, 21 Mar 1994 12:44:16 -0500
From: Adam Carlson <carlson%lindy@cs.umass.edu>
I have tried using the recently posted select-file function in an
application which has its top-level based on the clim lisp-listener
demo.
The following code may be added to the code I posted in my previous
message with questions about the listener. If you type :Choose File
then a file browser box comes up, but then after you hit OK, a second
file browser appears and the result of that select-file and the first
one appear to be concatenated. A notification is made about
extraneous characters in the input, and the input is not usable. I
can reproduce this by typing (accept 'command) at the listener prompt
(implying that the problem is in (accept 'command), not the listener
or (accept 'command-or-form), but when I create a similar command in a
non-listener application, it works fine.
I traced accept and select-file, and it appears that (accept
'command-or-form) calls (accept 'command), which calls (accept
'command-name) and then (accept 'my-pathname) which calls select-file,
select-file returns, (accept 'command) throws. Then (accept 'command)
is called again, leading to a second select-file. My guess is that
the way the accept command method is implemented it does one pass
which gets the input and a second which constructs the command object.
The real problem here is that your code is not taking the input editor
into account. The control flow of the input editor loops, which is
why you are the parsing functions are being called more than once.
I also have a question about programmatic interaction with the
file-browser. The original post said select-file specializes on
application-frames so that you could customize its behavior. I would
like to change the default filter (in particular, I'd like to specify
the file type, or filename extension that is acceptable.) How do I go
about doing that. There isn't any documentation on how to communicate
to select-file.
;;;-------------------------------------------------------------------
;;; Select-file
;;;-------------------------------------------------------------------
(define-presentation-type my-pathname () :inherit-from '(pathname))
#+clim-2
(define-presentation-method accept ((type my-pathname)
(stream t) (view t) &key)
(let ((pathname (select-file *application-frame*)))
(presentation-replace-input stream pathname 'pathname view)
(values pathname 'my-pathname)))
My guess is that you want the accept method above to check the value
of stream-rescanning-p. When it is NIL, this should do just what you
have above. When T, it should call (accept 'pathname).
This is a pretty subtle thing here...
(define-lisp-listener-command (com-choose-file :name t :menu t)
((pathname 'my-pathname :prompt #+clim-1 "Pathname" #+clim-2 nil))
(present pathname 'pathname))
(define-lisp-listener-command (com-another-choose-file :name t :menu t)
()
(let ((pathname (accept 'my-pathname)))
(terpri)
(present pathname 'pathname)))
References:
Main Index |
Thread Index