[plt-scheme] using inherit-field when making new gui widgets

From: Stephen De Gabrielle (spdegabrielle at gmail.com)
Date: Fri Oct 5 11:35:19 EDT 2007

Thanks, I'd just worked out it was an initialisation arg- I assume it is
created something like this

(define person%
  (class object%
    (init name)
    (define -name name)
    (super-new)
    (define/public (say-hello)
      (printf "hi, my name is ~a~%" -name))))

I think I'll use the second option - I don't want to change the value, and I
think it is less verbose in the end.

Thanks(again),

S.

On 10/5/07, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>
> At Thu, 4 Oct 2007 15:09:23 +0100, "Stephen De Gabrielle" wrote:
> > timeline-selector.ss::158: class*: superclass does not provide field:
> > min-width for class: timeline-selector%
> > (note the character offset - rather than the line number/character
> position
> > reported in bug 8954)
> >
> > I think I am using inherit field correctly, and the pane% I am using as
> a
> > superclass does have a 'min-width' field.
>
> The pane% class has a `min-width' method, not a field.
>
> The pane% class also has a `min-width' initialization argument. But you
> don't need to explicitly inherit it to use `min-width' with `super-new'
> or `super-initialize'.
>
> I think you want
>
>   (define timeline-selector% (class pane% ()
>                                (init min-width)
>                                ; Make the drawing area
>                                (super-new [min-width min-width]
>                                           ....)
>                                ....
>                                (define canvas (new canvas%
>                                                    [parent this]
>                                                    ....
>                                                    [min-width min-width]
>                                                    ....))
>                                 ....))
>
> or maybe
>
>
>   (define timeline-selector% (class pane% ()
>                                (inherit min-width) ; inherit method
>                                ; Make the drawing area
>                                (super-new ....)
>                                ....
>                                (define canvas (new canvas%
>                                                    [parent this]
>                                                    ....
>                                                    ;; call method to get
> arg:
>                                                    [min-width (min-width)]
>                                                    ....))
>                                 ....))
>
>
> Matthew
>
>


-- 
Cheers,

Stephen



--
Stephen De Gabrielle
s.degabrielle at ucl.ac.uk
Telephone +44 (0)20 7679 5242 (x45242)
Mobile                  079 851 890 45
http://www.uclic.ucl.ac.uk/annb/MaSI.html
University College London Interaction Centre
Remax House - 31/32 Alfred Place
London - WC1E 7DP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20071005/10e51571/attachment.html>

Posted on the users mailing list.