有人可以告诉我为什么下面的代码不起作用吗?它应该在加载时在字段中设置日期,然后允许通过单击该字段来更改日期。我在 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
最佳答案
这是代码的清理版本:
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
主要问题是在调用 layout
之前缺少对 paren 表达式求值的 compose/deep
调用。但是,这种方法不是初始化面属性的常用方法,您应该将初始化代码放在 VID block 的 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
希望这有帮助。
关于rebol - rebol2 vid 应用程序中的请求日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39816649/