Subclass method -distorted now put again
June
somewhere at so.com
Wed May 7 15:43:42 PDT 2008
Jarrett Billingsley Wrote:
> "BCS" <BCS at pathlink.com> wrote in message
> news:fvsdh5$2hii$11 at digitalmars.com...
>
> > so "setText("speaker", "foo") would call speaker.setText("foo")?
YES
> >
> > D doesn't support this directly, however you could do it manually
> >
> > void setText(char[] name, char[] text)
> > {
> > switch(name)
> > {
> > case "speaker": speaker.setText(text); break; What is diff here? -none
> > case "radio": radio.setText(text); break;
> > default: assert(false);
> > }
> > }
>
> In this case, it seems like keeping the controls in an AA would make a lot
> more sense.
>
> class MyWindow
> {
> Control[char[]] controls;
>
> this()
> {
> controls["speaker"] = new Slider();
> controls["radio"] = new Button();
> }
>
> void setText(char[] name, char[] text)
> {
> controls[name].setText(text);
> }
> }
>
>
Dont see how this applies .
I want to add a function to 'dwt.widgets.Text' that takes two char arrays and alters the text in an instance of dwt.widgets.Text'
dwt.widgets.Text' only has a function that takes one char array ? setText(char[] text)
Sorry if confusing a womans perogative no?
More information about the Digitalmars-d-learn
mailing list