CLIM mail archive


CLIM2 : bug in accept-method with pop-up menu

   Date: .31 Mar 94 11:02:20 +0000
   X400-Trace: BE*RTT*NRB
	   arrival .31 Mar 94 11:02:20 +0000
	   action Relayed
   Importance: normal
   Autoforwarded: FALSE
   P1-Message-Id: be*rtt*nrb;ccmacmta Mar 31 11:02:19 1994
   Ua-Content-Id: 190211310394
   P1-Content-Type: P2
   Priority: normal

   Has somebody already seen such a bug in clim2 with genera 8.3 (note that this 
   code worked well in clim1.1)?

The basic problem here is that this presentation type is not
interacting correctly with the input editor.  Here are a few key
things to know:

 - All calls to ACCEPT on an interactive stream take place inside of
   the input editor.
 - The input editor has a control structure that loops.

There is another problem with your ACCEPT method -- you don't want to
use PRESENT in it.

   Suppose I define a presentation type like this :

   (clim:define-presentation-type my-string ()
     :inherit-from 'string
     :description "One string from a subset")

   with an accept-method which pops up a menu, like :

   (clim:define-presentation-method clim:accept        
       ((type my-string) stream (view clim:textual-view) &key)
     (let ((chosen-word (pop-up-words-list stream type)))
       (clim:present chosen-word 'string :stream stream)

I did not test the following, but here is what I would use:

(clim:define-presentation-method clim:accept
    ((type my-string) stream (view clim:textual-view) &key)
  (if (clim:stream-rescanning-p stream)
      (let ((bp (clim:stream-scan-pointer stream))
	    (chosen-word (pop-up-words-list stream type)))
        (clim:presentation-replace-input stream chosen-word 'string view
					 :buffer-start bp)	
	(values (clim:accept 'string :stream stream :prompt nil))))

   (defun pop-up-words-list (stream type)
     (declare (ignore type))
       '("one" "two" "three" "four")
       :scroll-bars :dynamic
       :associated-window stream
       :pointer-documentation "Select one-word"))

   Then I try to use this presentation-type in a command :

     (com-test1 :command-table configuration-others :name t)
       ((arg 'my-string :prompt "Use menu to select word"))
     (format (clim:frame-standard-output clim:*application-frame*) "~A" arg))

   Every time I use this command, the pop-up menu for the command argument 
   appears twice.

   The value I select the second time is the one used for the body of the command.
   Another thing very strange is that, if you define the command with the keyword 
   :menu :

     (com-test1 :command-table configuration-others :name t :menu t)
       ((arg 'my-string :prompt "Use menu to select word"))
     (format (clim:frame-standard-output clim:*application-frame*) "~A" arg))

   then, when you write the command in the interactor pane the same problem 
   appears. But, if you use the command-menu pane to select the command, the it 
   works well...

   I have also written presentation types with other kinds of 
   menus that pop up in accept and the same problem appears.

   Should I have used the macro clim:define-presentation-action for this? In that 
   case, could someone give me some examples of its use?

Follow-Ups: References:

Main Index | Thread Index