[racket] How to use reparent - no such method: adopt-child for class

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Tue Apr 3 14:42:49 EDT 2012

Hi All,

My attempt to implement a slider with snapable values, ticks and
keyboard + and -
is almost done. The basic slider functionality works.

This will create a slider, where with ticks at 0, 10, ... ,
And the user can only select values from 0.0, 12.5, ... .

(define basic-slider
  (new basic-slider%
       [parent frame]
       [tick-values    (list 0 10 20 30 40 50 60 70 80 90 100)]
       [snap-values  (list 0.0 12.5 25.0 37.5 50.0 62.5 75.0 87.5 100.0))]
       [init-value 20.0]))

The basic-slider% is implemented as a subclass of canvas% implementing
the control<%> interface.

The builtin slider% supports a label to the left of the actual slider.

I therefore attempted to make a new class that within
a horizontal pane would hold both a message for the label
and the basic-slider. In order to this I tried to use reparent,
but got the error message

send: no such method: adopt-child for class: .../private/wxpanel.rkt:723:4

(define basic-slider-with-label%
  (class* basic-slider% (control<%>)
    (init parent)
    (define pane (new horizontal-pane% [parent parent]))
    (define message (new message% [parent pane] [label "foo"]))
    (super-new [parent pane])
    (send this reparent pane)
    (new message% [parent pane] [label "bar"])))

I suspect this is a bug?

However, I might not need reparent at all.
Is there a better way to add the message to the left of the
basic slider?

-- 
Jens Axel Søgaard


Posted on the users mailing list.