chance the (dynamic) data
[1/9] from: th72:dds:nl at: 5-Sep-2005 11:17
Hi,
I would like to chance the (dynamic) data property of the choice button
in view.
Something like this:
view layout [
c1: choice "yes" "no"
button [c1/data: ["true" "false"] ]
]
But this is not working as I suspected. Can someone give me a hint?
Thanks Tim
[2/9] from: SunandaDH:aol at: 5-Sep-2005 5:27
Tim:
> But this is not working as I suspected. Can someone give me a hint?
view layout [
c1: choice "yes" "no"
button [c1/texts: ["true" "false"]
c1/text: "true"
show c1
]
]
three hints:
-- c1/data is the "internal" value -- first data will be the value selected.
The displayed value is in c1/texts. I know it doesn't make obvious sense.
-- changing c1/texts does not change the current label -- strange but true.
Hence the setting of c1/text
-- to get *any* change in a field to show, us 'show
{I suppose you ought to update c1/data too -- just in case any code checks
the current value before the user makes a change]
Sunanda.
[3/9] from: compkarori::gmail::com at: 5-Sep-2005 21:43
Hi Tim,
Try this out ..
view layout [
c1: choice "yes" "no"
button "change" [c1/texts: copy ["true" "false"] c1/text: copy
true
show c1]
]
On 9/5/05, Tim Hendriks <[th72--dds--nl]> wrote:
> Hi,
> I would like to chance the (dynamic) data property of the choice button
<<quoted lines omitted: 9>>
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
--
Graham Chiu
[4/9] from: th72::dds::nl at: 5-Sep-2005 12:44
It's more difficult then I thought. The next problem is that I want to
use this in a iterrated list. For every row in the list it has to be
possible to chance the choice-buttons independent of each other, the
data is comming from a database-block. I think I'am missing some copy
statement somewhere. I tried several options but nothing is working.
The choice-buttons get changed but they are not working independent,
only the first one. So there is some problem with sharing....
Thanks for any help.
rebol []
db: [
["1" "question 1 " ["true" "false"]]
["2" "question 2" ["true" "false"]]
["3" "question 3" ["true" "false"]]
]
offset: 0
db-size: does [length? db]
out: layout [
text "list example"
across
mylist: list 640x480 [across t1: text 50 t2: text 200x40 para
[wrap?: true] c1: choice "1" "2" ] supply [
supply-data face count index
]
sld: scroller 10x480 [offset: to-integer sld/data * db-size show mylist]
]
supply-data: func [face count index /local temp] [
temp: count + offset
either temp <= db-size [
switch index [
1 [face/text: do to-path compose [db (temp) 1]]
2 [face/text: do to-path compose [db (temp) 2]]
3 [face/texts: do to-path compose [db (temp) 3] face/text:
do to-path compose [db (temp) 3 1]]
;3 [face/texts: copy ["ja" "nee"] face/text: copy "ja" ]
]
]
[face/text: none]
]
view out
rebol []
db: [
["1" "question 1 " ["true" "false"]]
["2" "question 2" ["true" "false"]]
["3" "question 3" ["true" "false"]]
]
offset: 0
db-size: does [length? db]
out: layout [
text "list example"
across
mylist: list 640x480 [across t1: text 50 t2: text 200x40 para
[wrap?: true] c1: choice "1" "2" ] supply [
supply-data face count index
]
sld: scroller 10x480 [offset: to-integer sld/data * db-size show mylist]
]
supply-data: func [face count index /local temp] [
temp: count + offset
either temp <= db-size [
switch index [
1 [face/text: do to-path compose [db (temp) 1]]
2 [face/text: do to-path compose [db (temp) 2]]
3 [face/texts: do to-path compose [db (temp) 3] face/text:
do to-path compose [db (temp) 3 1]]
;3 [face/texts: copy ["ja" "nee"] face/text: copy "ja" ]
]
]
[face/text: none]
]
view out
Graham Chiu wrote:
[5/9] from: greggirwin:mindspring at: 5-Sep-2005 9:59
Hi Tim,
TH> It's more difficult then I thought. The next problem is that I want to
TH> use this in a iterrated list. For every row in the list it has to be
TH> possible to chance the choice-buttons independent of each other...
You're running into a limitation of the LIST style. It doesn't work
for faces with state, because the same face is really used over and
over in the list. I think Brett or Anton has a check-list style that
might give you the clues you need to make it work.
-- Gregg
[6/9] from: antonr::lexicon::net at: 6-Sep-2005 3:30
Hi Tim,
Yes, I suggest change of strategy.
CHOICE style is very complex, getting it to
iterate would be difficult.
So it's better to use some other simpler style (such as a TEXT)
and only pop up the menu with CHOOSE (which is what the CHOICE
style uses) when you are changing the value.
do
http://www.lexicon.net/antonr/rebol/gui/iterated/demo-list-of-texts-with-con
text-menu.r
Note I added an extra field to your db block.
You might want to modify the above code to use the
series index of the ["true" "false"] blocks to
indicate the value that should be shown.
Then you don't need an extra field.
Anton.
[7/9] from: th72:dds:nl at: 5-Sep-2005 20:32
Thanks,
I stop trying now. It works perfectly with buttons, it works a little
bit with the toggle style but absolutely not with the choice style. I
wil change strategy now. I'am now trying to use the simple text-list and
then pop-up a new window when you select a list item.
This is one of my first experiments with the list style. It did looked
promissing with the buttons... It's a fun language with a lot of suprises.
Thanks for the help!
Tim
Anton Rolls wrote:
[8/9] from: th72:dds:nl at: 5-Sep-2005 20:56
Hi Anton,
I looked at your code. Interesting solution, thanks for your work. I
understand now that programming with the list style en choice is al
littebit more complex then I thought. I' am just a beginner, maybe i
should try something less complex :-)
Tim
Anton Rolls wrote:
[9/9] from: antonr::lexicon::net at: 6-Sep-2005 22:49
Thankyou Tim,
One day, I assure you, lists will not be so complex.
Anton.
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted