Problem updating a pane before being displayed
[1/3] from: jvargas:whywire at: 5-May-2003 13:58
Hello all. I am trying to create some dynamic forms. I am initializing
and hiding some faces before they get displayed. However I get odd
results, sometimes things get displayed correctly others not. Here is a
sample code of what I am doing. Am I missing something? Is there a
better way to change the look and feel of a layout before it gets
displayed?
Thanks, Jaime
REBOL[]
update-one: does [
either equal? vmenu/text "opt1" [
vlbl1/text: "lbl1"
vfld1/text: "text for fld1"
hide [vlbl2 vfld2]
show [vlbl1 vfld1]
][
vlbl2/text: "lbl2"
vfld2/text: "text for fld2"
hide [vlbl1 vfld1]
show [vlbl2 vfld2]
]
]
main: layout [
button "Pane One with fld1" 150 [
vpane/text: "one"
panels/pane: get to-word vpane/text
vmenu/text: "opt1"
update-one
view/new l1
]
button "Pane One with fld2" 150 [
vpane/text: "two"
panels/pane: get to-word vpane/text
vmenu/text: "opt2"
update-one
view/new l1
]
]
l1: layout [
across
vpane: choice "one" "two"
[ panels/pane: get to-word value show panels ]
return
panels: box 300x300
]
one: layout [
backcolor white
across
h2 "This is Pane One"
return
label "Menu" 80
vmenu: choice "opt1" "opt2"
[ update-one ]
return
vlbl1: label 80
vfld1: field 150
return
vlbl2: label 80
vfld2: field 150
return
]
two: layout [
backcolor white
across
h2 "This is Pane Two" return
text "It is empty for the moment"
]
center-face main
view main
[2/3] from: alanwall::sonic::net at: 5-May-2003 17:48
At 01:58 PM 5/5/03 -0400, you wrote:
[3/3] from: jvargas:whywire at: 6-May-2003 10:28
The problem happens only when displaying for the first time. When
displaying layout "l1" with pane "one" the vlbl2 and vfld2 faces should
be hidden. I only get vlbl2 hidden and vfld2 showing. This behavior is
corrected once a refresh event is generated ie. by playing with vmenu.
Any how I found a solution, but I am not sure if this is the best way
to solve it. Instead of:
update-one: does [
either equal? vmenu/text "opt1" [
vlbl1/text: "lbl1"
vfld1/text: "text for fld1"
hide [vlbl2 vfld2]
show [vlbl1 vfld1]
][
vlbl2/text: "lbl2"
vfld2/text: "text for fld2"
hide [vlbl1 vfld1]
show [vlbl2 vfld2]
]
]
I am using
update-one: does [
either equal? vmenu/text "opt1" [
vlbl1/text: "lbl1"
vfld1/text: "text for fld1"
vlbl2/show?: false
vfld2/show?: false
vlbl1/show?: true
vfld1/show?: true
][
vlbl2/text: "lbl2"
vfld2/text: "text for fld2"
vlbl2/show?: true
vfld2/show?: true
vlbl1/show?: false
vfld1/show?: false
]
]
The latter one works all the time even when displaying l1 for the first
time.
Is there a bug with the show and hide functions?
Thanks,
Jaime
PS. I am using REBOL/View 1.2.8.3.1
On Monday, May 5, 2003, at 08:48 PM, Alan Crandall wrote: