[plt-scheme] MrEd Graphics Questions

From: Robby Findler (robby at cs.uchicago.edu)
Date: Sat Apr 14 09:38:39 EDT 2007

On 4/13/07, Williams, M. Douglas <M.DOUGLAS.WILLIAMS at saic.com> wrote:
> First, does the basic structure of the graphical
> elements makes sense?  For example, I am using an editor-canvas% instance to
> the main output.  It works fine, but, for instance,  I would like to make it
> not editable since I am using it just for output.

Try calling the `lock' message with #t. (note you'll need to unlock it
when you insert something and then re-lock it when you're done)

>  Also, in the Options... menu item (under Edit), I am using text-field%
> instances and string->number to input simulation parameters.  Is there a
> better method for doing this that would make checking values easier.  In the
> same light, I would like to check the values when the field is exited.  Is
> there a way to do that?

You can pass a callback method to a text-field% that gets called on
each keystroke. You can use that to do some checking. If the text is
bad, you might just use something like this (where `e' is bound to the
text% object in the text-field%).

    (send e change-style
          (send (make-object style-delta%) set-delta-background (if on? "yellow"
          0 (send e last-position)))

to turn the text yellow, instead of rejecting it outright (then use
the ok button callback to reject the input when it is malformed).


Posted on the users mailing list.