[plt-scheme] (define pb-snips (map (λ (sni p) (send snip copy)) graph-snips))

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jun 21 05:54:17 EDT 2007

At Thu, 21 Jun 2007 10:26:08 +0100, "Stephen De Gabrielle" wrote:
> I've been trying to copy snips,(editor-snip and image-snip using graph-snip
> from the MrLib Graph library )
> 
> Copying the snips seems fine;
> (define pb-snips (map (λ (snip) (send snip copy)) graph-snips))
> 
> until I try to use one of my own methods
> 
>   (define my-image-graph-snip%
>     (class (graph-snip-mixin image-snip%)
>       (define/override (resize x y) #f) ;; do not allow resizing
>       (super-new)))
> 
> The copy operation doesn't bring the overridden method along.
> 
> I have since discovered that the copy operation needs to be overridden for
> my snip too, but I am not sure how to - any hints as to how I should
> approach this?

Is it as simple as overriding the `copy' method?:

   (define my-image-graph-snip%
     (class (graph-snip-mixin image-snip%)
       (define/override (resize x y) #f) ;; do not allow resizing
       (define/override (copy)
          (new my-image-graph-snip% ...))
       (super-new)))


If you need cut-and-paste to work (through the clipboard), then see also
the `snip%' documentation:

 http://download.plt-scheme.org/doc/370/html/mred/mred-Z-H-984.html

The second set of bullets is about cut-and-paste.


Matthew



Posted on the users mailing list.