Search code examples
rackettyped-racket

Typed Racket extend gui classes


I want to extend the class horizontal-panel%but somehow I am getting this error message:

class has init `stretchable-height' that is not in expected type in: (class horizontal-panel% (super-new))

This is my code so far:

#lang typed/racket
(require typed/racket/gui)

(define-type Graph-Tab%
  (Class #:implements  Horizontal-Panel%

         ))
(: graph-tab% : Graph-Tab%)
(define graph-tab%
  (class horizontal-panel%
    (super-new)

    ))

As you can probably tell I am very new to racket and I am still learning.


Solution

  • I'm pretty sure what that error message means is that you need to "init" all of the things from that class.

    One useful way to do this is to change from #:implements to #:implements/inits in your type definition and call init on the missing value(s) (in this case stretchable-height).

    If you don't know exactly what those are, you can simply put (init-rest) and that should take care of it.

    (here's the documentation for Initialization Variables and also for horizontal-panel%)