i feel like im missing something simple here maybe … ive been following the guide on implimenting snips. #lang racket/gui
(define thing (make-object string-snip% "hello"))
(define collapsable-snip%
(class snip%
(init given-child)
(define open? #f)
(define child given-child)
(super-new)
(define/public (get-child) child)
(define/override (draw dc x y left top right bottom dx dy draw-caret)
(send child draw dc x y left top right bottom dx dy draw-caret))
(define/override (get-extent dc x y w h descent space lspace rspace)
(send child get-extent dc x y w h descent space lspace rspace))
))
(define colapsable/thing (make-object collapsable-snip% thing))
(send colapsable/thing get-child)
colapsable/thing
currently im just trying to “wrap” a snip
But all I get is some empty space?
I figured if I delicate the draw method to the internal snip it should draw the internal one for me?
@chris613 Define a copy method. I believe DrRacket makes a copy, and then draws.
E.g. (define/override (copy) (make-object collapsable-snip% child))
(But this reuses the child - maybe call the copy method on the child instead)
Ahhhh brill thanks!
seems like if the draw method throws an error when printing to repl it can freeze drracket. is this normal?
also, tried your method and works great so thanks!
@chris613 Don’t know it is normal. @robby will know.
@robby has joined the channel
Yes a buggy snip can break drr.
This is a bug in drr but not a simple one to fix
It is a problem only when you return snips to the REPL
Inserting them into a text% object and showing that in your own frame causes no problems.
i assume thats somethign to do with the error essentially braking into the drracket “scope” or something by being returned to the repl ?
thanks for the clarification though :slightly_smiling_face:
roughly speaking, when an error happens due to a callback to a snip that is in the interactions window, it counts as being a part of DrRacket’s implementation instead of the program in the definition window’s implementation (which is wrong — it should still count as being part of the definitions window’s program)
So all kinds of things can go wrong, not just mishandled errors, actually :disappointed: