[plt-scheme] after-insert works differently than after insert

From: Mike T. Machenry (dskippy at ccs.neu.edu)
Date: Mon Aug 9 18:23:30 EDT 2004

Here's another oddity that I cannot figure out if it's a bug or not. Could 
some explain to me why this is behaving this way? In the following program I 
override after-insert to get-snip-location of the snip and I also 
get-snip-location of the snip after insert, meaning on the last line of the 
program after the call to insert. I would imagine that snip would have the 
same location in these places but it does not.

If this is intended behavior, I would like to know how to get the correct 
information from within after-insert.

Thank you,

-mike

(require
 (lib "class.ss")
 (lib "mred.ss" "mred"))

(define (snip-loc apasteboard asnip)
  (let ([left (box 0)]
	    [right (box 0)])
    (send apasteboard get-snip-location asnip left (box 0) #f)
    (send apasteboard get-snip-location asnip right (box 0) #t)
    (printf "~s ~s~n" (unbox left) (unbox right))))

(define aligned-pasteboard%
  (class pasteboard%
    (inherit get-snip-location)
    (rename [super-after-insert after-insert])
    (define/override (after-insert snip before x y)
      (super-after-insert snip before x y)
      (snip-loc this snip))
    (super-new)))

(define f (new frame% (label "f") (height 500) (width 500)))
(send f show #t)
(define p (new aligned-pasteboard%))
(define c (new editor-canvas% (editor p) (parent f)))
(define s1 (make-object string-snip% "One"))
(send p insert s1)
(snip-loc p s1)


Posted on the users mailing list.