I'm setting up a very simple snip class that is based on the example in the documentation (
I was able to generate a snip that is a circle that grows in size when the up arrow key is pressed. However, after running the program again for some reason I ran into this bug:
error while rendering snip "test-snip":
should have been overridden context:
(...higher-order.rkt:364:33 . #f)
(.../more-scheme.rkt:261:28 . #f)
(loop . #(struct:srcloc #<path:/Applications/Racket v7.2/share/pkgs/gui-lib/framework/private/text.rkt> 2940 6 114655 2217))
(|do-insertion method in ports-mixin| . #(struct:srcloc #<path:/Applications/Racket v7.2/share/pkgs/gui-lib/framework/private/text.rkt> 2933 4 114420 2804))
(#f . #(struct:srcloc #<path:/Applications/Racket v7.2/share/pkgs/gui-lib/framework/private/text.rkt> 2926 9 114164 107))
(#f . #(struct:srcloc #<path:/Applications/Racket v7.2/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt> 435 6 19067 1056))
(#f . #(struct:srcloc #<path:/Applications/Racket v7.2/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt> 486 32 21054 120))
(#f . #(struct:srcloc #<path:/Applications/Racket v7.2/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt> 634 3 26076 58))
;; snip-class
(define test-snip-class
(make-object
(class snip-class%
(super-new)
(send this set-classname "test-snip"))))
;; snip stuff
(define scroll-snip%
(class snip%
(inherit get-admin set-snipclass set-flags)
(init-field [w 50] [h 50])
(super-new)
(set-snipclass test-snip-class)
(send (get-the-snip-class-list) add test-snip-class)
(set-flags (list 'handles-events))
(define/override (get-extent dc x y width height descent space lspace rspace)
(define (maybe-set-box! b v) (when b (set-box! b v)))
(maybe-set-box! width w)
(maybe-set-box! height h)
(maybe-set-box! descent 1.0)
(maybe-set-box! space 1.0)
(maybe-set-box! lspace 1.0)
(maybe-set-box! rspace 1.0))
(define/override (on-char dc x y editorx editory event)
(cond
[(equal? (send event get-key-code) 'up)
(define admin (get-admin))
(set! w (+ 20 w))
(set! h (+ 20 h))
(when admin
(send admin resized this #t))]))
(define/override (draw dc x y left top right bottom dx dy draw-caret)
(send dc set-brush "red" 'solid)
(send dc set-pen "black" 3 'solid)
(send dc draw-ellipse (+ x 1.0) (+ y 1.0) (- w 2) (- h 2)))
(define/override (copy)
(new scroll-snip%))
))
(new scroll-snip%)