CLIM mail archive


Problem combining Keyboard and Mouse input

  I have been having a difficult problem that I thought someone on the
net has surely solved.  I have a CLIM application (Allegro's version)
with two application panes and one interactor pane.  The application
panes display information in the form of graphs and tables that can
be pulled into the interactor pane by clicking the right mouse button
when the mouse cursor is over the desired piece of information.  This
information always consists of a string represented a name of a node
in the graph or sample text strings.

  The problem is that in the interactor I want to allow the user to 
enter text from the keyboard and/or select text from the other panes 
with the mouse to form ONE string.

For example, given the prompt = "Enter Information", the user could
enter the following:

Enter Information: this is typed in from the keyboard, <this is selected
with the mouse>, and this is additional keyboard input.  

To accomplish this, I created a presentation type called "segmented-string"
defined below:

    (clim:define-presentation-type seg-string nil)
          clim:accept ((type seg-string) stream (view clim:textual-view) &key)

          (let ((char nil)(s " ") (slist "") (done nil))
              ; until a #\newline is pressed...
              (loop while (not done) do

                    ; accept a regular string terminated by a return or space
                    (setq s (clim:accept 'string :prompt nil

                    ; determine last character read
                    (case (setq char (clim:read-gesture :stream stream))
                          ; if the last character was a space...

                                ; append s to slist with a trailing space 
                                (if (> (length s) 0) 
                                    (setq slist (format nil "~A~A " slist s)))

                          ; if the last character was a #\newline...

                                ; append s to slist, and we're now done
                                (if (> (length s) 0)
                                     (setq slist (format nil "~A~A" slist s))

                                (setq done t)
                         ; otherwise, append s to slist
                                (if (> (length s) 0) 
                                    (setq slist (format nil "~A~A" slist s)))

              ; if we captured something, return it.
              (if (> (length slist) 0) slist)
   (clim:define-presentation-method clim:present
       (object (type seg-string) stream (view clim:textual-view) &key)
       (apply #'format stream "~A " object)

This code works except that the spaces between words are not displayed
in the interactor pane, which for the above example would give:

Enter Information: thisistypedinfromthekeyboard,<this is selected
with the mouse>,andthisisadditionalkeyboardinput.

Now the resulting string slist is ok, i.e., the spaces are where they
should be. It's just that when the user is entering text all the words
are shoved together.  I tried adding a format statement in the Space
part of the case, but for some reason when the space is displayed, the
pane cursor is not advanced and the very next character "overwrites"
the space.

The code above works fine on the Symbolics, it's just the Allegro
version which is acting up.

Any pointers towards the solution of this problem would be greatly

Richard Hull

Main Index | Thread Index