[REBOL] Re: Dynamically Changing the 'text of Button
From: gjones05:mail:orion at: 18-Jun-2001 8:57
From: "CRS - Psy Sel/SPO, COUSSEMENT, Christophe, CPN"
> A little problem I couldn't resolve right now: how can I dynamically change
> the 'text property of a button ?
>
> Let's consider this code:
>
> <snip>
>
> rebol []
>
> view layout [
> b: button "First Text"
> button "Change" [
> b/text: "Second Text"
> print ["Button *Change* pressed:" b/text]
> show b
> ]
> button "Echo" [
> print ["Button *Echo* pressed:" b/text]
> ]
> ]
>
> </snip>
>
> I got:
>
> >> do %test.r
> Button *Change* pressed: Second Text
> Button *Echo* pressed: First Text
>
> And, of course, the 'text of b wasn't updated ;-(
>
> How come ?
Hi, Christophe,
I offer the following option but I have to admit that I do not know why this
works, nor why button is different than the other controls. Note that a block
is passed to b/texts (which is the plural form):
view layout [
b: button "First Text"
button "Change" [
b/texts: ["Second Text"]
print ["Button *Change* pressed:" b/text]
show b
]
button "Echo" [
print ["Button *Echo* pressed:" b/text]
]
]
--Scott Jones