CLIM mail archive

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

Accept problem




      I'm having trouble getting the following code to work.  What I want
is to have an input field where I can enter text or click on an object
and have a text description of that object inserted into the field.  The
problem is that whenever I click on the object, the input immediately
terminates, saving only the text that was translated from the object.
Any text that was in the input field before the click is lost.  What
I'd rather happen is that the text from the translated object gets
inserted as if it was just typed in.  Also, I'd prefer that the input field
only terminates when the user hits <return>.
      Any help is appreciated.

      Thanks,

         Erik Eilerts
         University of Texas at Austin
         eilerts@cs.utexas.edu


The following code is my attempt to get this to work.  I've tried many
types in the accept call, including some or's, but nothing seems to work.
----------------------------------------------------------------------------

(defclass SLOT-VALUE ()
    ((svalue :initarg :svalue :accessor svalue :initform nil)))

(clim::define-presentation-type slot-value ())

(clim::define-presentation-method clim:present
    (sv-object (type slot-value) stream (view clim:textual-view) &key)
  (format *terminal-io* "~% presenting ~a (~a)"  sv-object (svalue sv-object))
  (write-string (format nil "~a" (svalue sv-object)) stream))

(clim:define-presentation-translator right-stuff-value-item
    (slot-value clim:string clim:global-command-table 
        :documentation "Stuff into buffer."
        :gesture :select)
    (object)
  (let ((str (format nil "~a" (svalue object))))
    (format *terminal-io* "~%Left-Mouse for ~a (~a)" object str)
    str))


(defun do-choose-menu (&optional (host (environment-variable "DISPLAY")))
  (let ((stream (if host 
		    (clim:open-root-window :clx :host host)
		    (clim:open-root-window :clx)))
	(slot (make-instance 'slot-value :svalue '(plant has-part leaf)))
	(result nil))
 
    (multiple-value-bind (x y) (clim:stream-pointer-position* stream)
      (with-simple-restart (abort nil)
        (clim:accepting-values
	   (stream :own-window '(:right-margin 200 :bottom-margin 30)
		 :label "Choose Value Input Window"
		 :resynchronize-every-pass nil
		 :x-position (- x 50) 
		 :y-position (- y 50))

	   (terpri stream)
	   (clim:present slot 'slot-value :stream stream)
	   (terpri stream)
	   (terpri stream)
	   (setf result (clim:accept 
			   '(clim:null-or-type string)
			   :prompt "Enter a Value"
			   :stream stream)))))

    result))


0,,


Main Index | Thread Index