[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:48:02 EDT 2012

I forgot to attach the program.

/Jens Axel


2012/4/3 Jens Axel Søgaard <jensaxel at soegaard.net>:
> 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



-- 
--
Jens Axel Søgaard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: slider.rkt
Type: application/octet-stream
Size: 7899 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20120403/b0311ba8/attachment.obj>

Posted on the users mailing list.