[racket] How to read custom editor-snip% from WXME file

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Jul 24 18:34:04 EDT 2013

At Wed, 24 Jul 2013 15:03:01 -0700, Nick Main wrote:
> I created an extended editor-snip% class (also using the graph-snip-mixin)
> and put an instance of this on a pasteboard% (altered
> via graph-pasteboard-mixin) and then saved the pasteboard to a file.
> 
> Reading this file back into the pasteboard fails (no visible errors
> either). Doing the same with a non-extended editor-snip does work, so the
> only change is the extension class.
> 
> From documentation and looking at the source (in the mred collection) I
> gather that I need to implement, set and register a custom snip-class%
> object for my custom editor-snip.
> 
> Since I am not, at this stage, adding anything to editor-snip% I would like
> to reuse the editor-snip% write method and the editor-snip-class% read
> method. Since editor-snip-class% is a private class I do not understand how
> I can extend it.
> 
> Is there a way to reuse the editor-snip-class% functionality without
> cut-and-paste?
> 
> I notice that editor-snip-class% uses a private top-level var
> "extended-editor-snip%" to hold the actual class of the snip that it
> creates. Is there any way to leverage this ?
> 
> I hope that I missed something obvious - there is a lot of machinery in
> WXME but nothing that makes this easy.

I'm not sure that this is a good answer, but you could use

  (send (get-the-snip-class-list) find "wxmedia")

to get an instance of `editor-snip-class%'.


Posted on the users mailing list.