[REBOL] Re: radio button
From: gscottjones:mchsi at: 21-Sep-2002 7:22
From: "Nicolas Maillard"
...
> i generate a script in dyn the data inside are not the same each time the
> file is created. so in this file i generated radio buttons whitch are like
> that :
> r1: radio of 'groupe1 text "INFO DYN1"
> r1: radio of 'groupe1 text "INFO DYN2"
> rn : radio of 'groupe1 text "INFO DYNn"
>
> a radion button for validate the choice.
>
> So i can't use r1/data or r2/data or rn/data because i never know if he
> exists. How can i recover dynamicaly the choice of th radio buton?
>
> for exemple if he choose the third choice can i use a thing like that :
> groupe1/data? or other thing
Hi, Nicolas, Graham, (and possibly Bertrand :-),
OK, I *think* I am understanding more of what you seek. Using some
techniques that I have used for passing on events (separate thread with Carl
R.), I'll iterate through all the faces looking for the r1 thru rn that
contain the "groupe1" marker. This could be done using other markers. In a
larger program, I could easily see confining the iteration routine to a
subface, like a pane that contains the radio buttons. Hopefully this is
getting very close to what you are seeking (watch for line wrap):
blk: copy []
repeat i 3 [
repend blk [
'across
to-set-word join 'r i 'radio
'of to-lit-word 'groupe1
'text join "my info" i
'below
]
]
append blk [
b: button "Show Radios" [
c: 1
clear t/data
while [l/pane/:c] [
if equal? l/pane/:c/facets [of groupe1] [
append t/data rejoin [
l/pane/:c/var
"^-"
get in l/pane/:c 'data
]
]
c: c + 1
]
show t
]
t: text-list 100x60
]
l: layout blk
view l
;######################
On second thought, if the example is less than clear, I have comment it
below:
;empty block to hold dynamically laid out window
blk: copy []
;throw in an arbitrary number of radios
; with groupe1 label
repeat i 3 [
repend blk [
'across
to-set-word join 'r i 'radio
'of to-lit-word 'groupe1
'text join "my info" i
'below
]
]
;throw in rest of the layout
append blk [
b: button "Show Radios" [
c: 1
clear t/data
while [l/pane/:c] [
;iterate through all the faces
;(could be narrowed if needed to smaller
; subset) and look for desired label
if equal? l/pane/:c/facets [of groupe1] [
;append the radio data info to text-list
append t/data rejoin [
l/pane/:c/var
"^-"
get in l/pane/:c 'data
]
]
c: c + 1
]
;update displayed text-list
show t
]
t: text-list 100x60
]
l: layout blk
view l
Let me know if I got the idea right this time. :-)
--Scott Jones