[plt-scheme] using inherit-field when making new gui widgets
Hi, I'm having a go at creating a new widget
But I am getting the error
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.
As I understand the manual, I need inherit field so I can access the field
in my subclass (in this case to make a canvas).
An inherit-field declaration makes a public field defined by a superclass
> directly accessible in the class expression. If the indicated field is not
> defined in the superclass, the exn:fail:object exception is raised when the
> class expression is evaluated. Every field in a superclass is present in a
> derived class, even if it is not declared with inherit-field in the derived
> class. The inherit-field clause does not control inheritance, but merely
> controls lexical scope within a class expression.
>
Can anyone let me know where I have gone wrong?
This is how I call the creation of my new class
(define timeline-selector (new timeline-selector% (parent
the-horizontal-pane)
(min-width 100) (min-height 800)
(stretchable-width #f) (stretchable-height
#f)))
; make new widget
(define timeline-selector% (class pane% ()
(inherit-field min-width
stretchable-width
min-height
stretchable-height )
(init-field parent )
; Make the drawing area
(super-instantiate () (parent parent)) ;
instantiate this FIRST
;; [min-width min-width]
[stretchable-width stretchable-width] ;; commented out as hopefully not
needed
;; (min-height min-height)
[stretchable-height stretchable-height])
;; internal data
(define list-of-points '()) ;; start with
empty list
(define canvas (new canvas% [parent this]
(style '(control-border))
(paint-callback (lambda
(canvas dc) (draw-chart)))
[min-width min-width]
[stretchable-width #f]
[min-height min-height]
[stretchable-height #f]
))
(define/public (get-dc) (send canvas get-dc))
; Get the canvas's drawing context
(... and so on)
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/20071004/6fbddcfd/attachment.html>