I can click to drag in order to draw a rectangle, but when i drag the
created rectangle (for position adjustment), a new rectangle is created
from the said position. How do i constrain/fix the issue? i have been
trying to use key-combination to draw a new rectangle on demand. can you
please give a hint?
```
#lang racket
(require racket/gui racket/draw pict)
(define my-pasteboard (class* pasteboard% ()
(init)
(super-new)
(define/override (on-default-event evt)
(new-rect evt))))
(define board (new pasteboard%))
(define toplevel (new frame%
[label "My board"]
[width 500]
[height 500]))
(define canvas (new editor-canvas%
[parent toplevel]
[editor board]))
(send toplevel show #t)
(define my-snip-class
(new (class snip-class%
(super-new)
(send this set-classname "my-snip"))))
(send (get-the-snip-class-list) add my-snip-class)
(define rectangle-snip%
(class snip%
(init-field w h)
(super-new)
(send this set-snipclass my-snip-class)
(define/override (get-extent dc x y width height . other)
(when width (set-box! width w))
(when height (set-box! height h)))
(define/override (draw dc x y . other)
(draw-pict (rectangle w h) dc x y))))
(define (new-rect) (send my-pasteboard insert (new rectangle-snip% [w 30]
[h 80]) 100 300))
```
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/CAGcmBVWOkibP%2BFnmrY9X-FDTmjfxMZQFXwHTzCqzguhb8RZwOw%40mail.gmail.com.