dynamic faces
[1/4] from: fabrice:regnier:socopa-entreprise at: 24-Dec-2001 10:40
Hi to all !
I'd like to modify the data refinement of some progress faces that i've created before.
I can create dynamicaly the faces but how to change the data refinement ?
Thanx in advance and Merry Christmas :)
Fab
here is my script :
monlayout: []
i: 1
for i 1 1 2 [
append monlayout reduce [
set to-word rejoin ["progress" i ] 'progress 12x100
'button rejoin ["modif " i] [
;set to-word rejoin [ "progress" i ] /data: 0.5
;show to-get-word rejoin [ "progress" i ]
]
];end-append
];end-for
append monlayout reduce [
'below
'button "Source" [source monlayout]
'button "Quitter" [quit]
];end-append
view layout monlayout
[2/4] from: sunandadh:aol at: 24-Dec-2001 7:52
Hi Fabrice,
> I'd like to modify the data refinement of some progress faces that i've
> created before.
> I can create dynamicaly the faces but how to change the data refinement ?
>
> Thanx in advance and Merry Christmas :)
> Fab
Here's a quick hack of your code. It works, but I'm sure others can fix it up
better. what I've done:
1. split the Append into an Append and an append/Only. This is an easy way to
get the extra pair of [] around the action facet
2. Simplified some of the expressions
3. Put a Print Mold in immediately before the View. That way you can see what
is about to be viewed.
4. Changed the View Load Monlayout to View Load Mold Monlayout
Without this last change the set-words in your MonLayout block are in the
wrong context, and the slider never updates.
The true experts will probably advise that you start over again, and use
Compose
Hope that helps,
Sunanda.
unview/all
monlayout: copy []
for i 1 2 2 [
append monlayout reduce [
to-set-word rejoin ["progress" i ] 'progress 12x100
'button rejoin ["modif " i]
];end-append
append/only monlayout reduce [
to-set-word join "progress" [i "/data"] 0.5
'show to-word join 'progress i
]; append/only
];end-for
append monlayout [
below
button "Source" [source monlayout]
button "Quitter" [quit]
];end-append
print mold monlayout
view layout load mold monlayout
[3/4] from: arolls:idatam:au at: 26-Dec-2001 16:05
Here is a way using compose:
lay-blk: copy []
repeat i 3 [append lay-blk [progress 12x80]] ; 3 progress bars
repeat i 3 [
append lay-blk compose/deep [
button (join "modif" i) [
lpi: (to-path compose [lay pane (i)]) ; <--
lpi/data: lpi/data + 0.1
show lpi
]
]
]
view lay: layout lay-blk
The use of i, where it is marked with an arrow, is critical.
If you change your layout, for example, to add a backdrop at
the beginning, as in:
lay-blk: copy [backdrop black]
then the index will be incorrect. You will need to add one
to it, like this:
lpi: (to-path compose [lay pane (i + 1)])
Of course you could add code to track where the progress
bars were inserted and add this offset at the appropriate
moments later in the code.
Note the use of compose/deep. It is /deep so that the reach
of compose extends into sub-blocks. The calculation for lpi
is within a sub-block, so we need compose/deep.
Anton.
[4/4] from: fabrice::regnier::socopa-entreprise::com at: 26-Dec-2001 9:55
Thanx to both of you Anton and Sunanda ;)
It helped me very much.
Fab