[plt-scheme] Re: scrolling inside an editor-snip?

From: harsha (harsha.v.r at gmail.com)
Date: Wed Oct 3 18:09:54 EDT 2007

thanks for the replies,
I tried scroll-to method, but it didn'work out, I am probably missing
something basic about the interface. right now the scroll-to methods
just return #f.

here's what i did :

;set up a canvas, pasteboard, editor-snip
(define f (instantiate frame% ("E" #f 400 400)))
(define c (instantiate editor-canvas% (f)))
(define p (instantiate pasteboard% ()))
(send c set-editor p)
(define s (instantiate editor-snip%()))
(send p insert s)
(send f show #t)

;define admin and editor, insert text, resize snip
(define a (send s get-admin))
(define ed (send s get-editor))
(send ed insert "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n" 0) ; 11 lines of
(send s resize 200 85) ;; enough height to display 4 lines

(define y (send s get-scroll-step-offset 6)) ; evaluates to around
119, the local y coordinate of the end of the 6th line

; none of these three work, they return #f
(send a scroll-to s 0 y 200 85 #t)
(send ed scroll-to-position 11) ; 11 is somwhere after the 5th line
(send ed scroll-to s 0 y 200 85 #t)

Posted on the users mailing list.