有人可以告诉我为什么以下代码不起作用?它应该在加载时在字段中设置日期,然后通过单击字段允许更改日期。我在linux上使用rebol / view 2.7.8。实际上,我认为这段代码曾经在我使用MS Windows时工作多年,但出于某种原因却不在linux下。
DRL
rebol []
trace true
out: layout [
style dater txt bold right [trans-date/date: copy (form now/date)] 48x24
dater "T-Date:" trans-date: field 80x24 (form now/date) feel [
engage: func [face action event][
if action = 'up [
lv-dat: request-date/date/offset (now/date) 450x375
if lv-dat <> none [
trans-date/text: form lv-dat
show trans-date
]
]
]
show trans-date
]
]
view out
答案 0 :(得分:4)
以下是代码的清理版本:
Rebol []
out: layout compose/deep [
style dater txt bold right 48x24
dater "T-Date:"
trans-date: field 80x24 (form now/date) feel [
engage: func [face action event][
if action = 'up [
lv-dat: request-date/date/offset (now/date) 450x375
if lv-dat [
face/text: form lv-dat
show face
]
]
]
]
]
view out
主要问题是在调用compose/deep
之前调用paren表达式时缺少layout
调用。但是,这种方法不是初始化face属性的常用方法,您应该将init代码放在VID块的do
部分中,如下所示:
Rebol []
out: layout [
style dater txt bold right 48x24
dater "T-Date:"
trans-date: field 80x24 feel [
engage: func [face action event][
if action = 'up [
lv-dat: request-date/date/offset now/date 450x375
if lv-dat [
face/text: form lv-dat
show face
]
]
]
]
do [trans-date/text: form now/date]
]
view out
希望这有帮助。