Hi all,<br><br>I'm having problems getting the contents in a text% to scroll within an editor-snip%.<br><br>The attached code displays part of a long string within a text% object in a smaller editor-snip% object. The print statements successfully show a few of the edit locations at some selected (x, y) points in the editor. <br>
<br>I think I've tried all of the scrolling functions in each of the various components (editor-canvas%, editor-admin%, editor-snip%, text%) and am unable to change the portion of the string that displays. I'm probably doing something stupid, can anyone give me any hints? <br>
<br>Cheers,<br><br>Kieron.<br><br>****<br><br>#lang racket/gui<br><br>(define f (instantiate frame% ("Pasteboard Test" #f 600 400)))<br>(define c (instantiate editor-canvas% (f)))<br><br>(define p (instantiate pasteboard% ()))<br>
(send c set-editor p)<br><br>(send f show #t)<br><br>(define t (new text% [auto-wrap #f]))<br>(send t insert "hello world .... pasteboard one two three ... goodbye world ... alpha bravo charlie delta echo foxtrot golf hotel india juliet kilo lima mike november oscar papa quebec romeo sierra tango uniform victor whiskey xray yacht zulu" 0)<br>
<br>(define s (new editor-snip% [editor t]))<br><br>(send s set-min-width 250)<br>(send s set-max-width 250)<br><br>(send p insert s)<br><br>(printf " text dimensions:(~a ~a) (~a ~a)~n" <br> (send t get-min-width) (send t get-min-height) <br>
(send t get-max-width) (send t get-max-height))<br>(printf " snip dimensions:(~a ~a) (~a ~a)~n" <br> (send s get-min-width) (send s get-min-height) <br> (send s get-max-width) (send s get-max-height))<br>
<br>;; print information about certain locations in the text<br>;(send t find-position x y at-eol? on-it? edge-close?) <br>(define at-eol? (box 0))<br>(define on-it? (box 0))<br>(define edge-close? (box 0))<br>
(printf " (5,5): ~a ~a ~a ~a~n" <br> (send t find-position 5 5 at-eol? on-it? edge-close?) (unbox at-eol?) (unbox on-it?) (unbox edge-close?)) <br>(printf " (25,5): ~a ~a ~a ~a~n" <br>
(send t find-position 25 5 at-eol? on-it? edge-close?) (unbox at-eol?) (unbox on-it?) (unbox edge-close?)) <br>(printf "(100,5): ~a ~a ~a ~a~n" <br> (send t find-position 100 5 at-eol? on-it? edge-close?) (unbox at-eol?) (unbox on-it?) (unbox edge-close?)) <br>
(printf "(200,5): ~a ~a ~a ~a~n" <br> (send t find-position 200 5 at-eol? on-it? edge-close?) (unbox at-eol?) (unbox on-it?) (unbox edge-close?)) <br>(printf "(400,5): ~a ~a ~a ~a~n" <br>
(send t find-position 400 5 at-eol? on-it? edge-close?) (unbox at-eol?) (unbox on-it?) (unbox edge-close?)) <br><br>;; scroll to certain locations in the text<br>(define (do-scroll-text)<br> (printf "scroll:~a~n" (send (send t get-admin) scroll-to -400 0 50 50 #t 'none))<br>
(sleep 1.0)<br> (printf "scroll:~a~n" (send t scroll-to s 200 0 50 50 #t 'start))<br> (sleep 1.0)<br> (printf "scroll:~a~n" (send p scroll-to s 400 5 50 50 #t 'start))<br> (sleep 1.0)<br>
(printf "scroll:~a~n" (send t scroll-to s 800 5 50 50 #t 'start))<br> (sleep 1.0)<br> )<br><br>(thread do-scroll-text)<br><br>