[mcclim-devel] Customizing interactor panes

Andy Hefner ahefner at gmail.com
Thu Jan 27 22:59:36 UTC 2005


This sort of thing is really determined by what the top-level loop of
the application does rather than any property of the interactor pane.
If you look at the top-level function in the listener, it simply peeks
at the first character typed and then decides whether to read a
command or a lisp form based on that. Unfortunately this is a rather
low-level way of doing things and at timess undermine some of the nice
features that McCLIM would normally provide (keyboard accelerator
gestures, completion, etc). I don't mind working around this to retain
absolute control, but I'd recommend a different approach.

CLIM contains an "or" presentation type which allows you to accept one
of a number of types. The default accept method for this type attempts
to read the first type in the list textually. If the accept method for
the first type in the list signals a parse error, it tries to read as
the next type, and so on. What might work for you is to define a
presentation type for elements and one for whatever else as "12g C
H4", with accept methods for each type which call your parser. Then
you can write a top-level loop that accepts '(or command element
whatever-else..) and examines second value returned (presentation type
of input) to decide what to do (call execute-frame-command, inpect
element, etc).

I haven't made much use of this technique, but it seems like right way
to do it. I'm concerned that the command parser may continue reading
and block you from entering things such as "Krypton". Things that
don't resemble command names, such as "12 g C H4", should work. If
this is indeed a problem, I'm sure we can find a way to make it work.


On Thu, 27 Jan 2005 13:52:25 -0700, Peter Scott <sketerpot at gmail.com> wrote:
> I'm writing a GUI for a chemistry program with McCLIM. My problem is
> that I want the user to be able to type commands into the interactor
> pane in a special syntax, which I have written a parser for. For
> example, typing "Krypton" should call the Inspect Element command on
> the element called "Krypton". Typing "12 g C H4" should display how
> many moles of methane there are in 12 g. There's more like that, but I
> have the code to handle it all written---except for the code that
> hooks it into an interactor pane.
> 
> There's a way of getting an interactor pane to differentiate between
> commands and s-expressions, for use in a listener, so I think that
> what I want is possible. Can anybody tell me how?



More information about the mcclim-devel mailing list