我想动态地将一个按钮添加到视图的布局中,导致添加的参与者属于一个已经是布局一部分的按钮。
我是这样开始的:
REBOL [title: "Dynamic Button Addition"]
tilesize: 60x60
curtile: 1
stylize [
p: button [
facets: [init-size: tilesize max-size: tilesize]
actors: [
on-action: [
++ curtile
append tiles compose [ p (to-string curtile) ]
print ? tiles/options/content
v/redraw
]
]
]
]
v: [
tiles: hgroup [ p "1" ]
]
view v每次单击时,...which的值似乎都不会发生变化。
如果进行以下更改,我可以让它更改:
append tiledata compose [ p (to-string curtile) ]和
tiledata: [ p "1" ]
v: [
tiles: hgroup tiledata但是,这不会在屏幕上引起任何变化。如果我用下面的代码替换最后四行:
v: view [
tiles: hgroup tiledata
]...so v现在是视图,而不是视图的布局,当我单击时,我得到这个错误:
** Script error: v has no value
** Where: actor all foreach do-actor unless do-face if actor all foreach do-actor if do-event do-event if do-event either -apply- wake-up loop -apply- wait forever try do-events if view do either either either -apply-
** Near: actor face :data这对我来说是有意义的,因为在我退出程序IIUC之前,v还没有完成定义。
那么,如何在程序结束之前,但在将其传递给view之后对v进行更改
发布于 2015-02-25 16:10:57
不是很好,但是如果你用
v/redraw有了这两行
unview/all
view v在how to update a layout that has already be viewed上有一个真正的动态示例
我会简化它
stylize [
tbox: hpanel [
actors: [
on-make: [
append face/options [
content: [
]
]
do-actor/style face 'on-make none 'hpanel
]
]
]
]
view/across [
button "button 1"
on-action [
append-content test compose [
button ( join "button " 2 + length? test/gob)
]
]
test: tbox
]https://stackoverflow.com/questions/28544063
复制相似问题