0

下面的代码工作正常,只是我想在创建推出之前动态更改标签文本,而不是之后。我试图在推出时将变量(rolloutlabel)作为字符串传递,只是我似乎无法做到这一点,而不必通过使用按钮更新它来围绕它进行编码。如果取消注释第 6 行,我得到的(无用)错误是“语法错误:在 =,预期名称”

rolloutlabel = "label"
rollout rolloutDialog "Rollout" width:100 height:50
(
    label alabel "" pos:[10,10] width:90 height:16
    button updateBTN "Update label" pos:[10,25] width:80 height:16
    -- alabel.text = rolloutlabel as string
    -- this just gets a syntax error if i leave it here uncommented
    on updateBTN pressed do
    (
        alabel.text = rolloutlabel
    )
)
createDialog rolloutDialog

知道我哪里出错了吗?

4

2 回答 2

3

看一下 rollout open 子句:

rolloutlabel = "label"
rollout rolloutDialog "Rollout" width:100 height:50
(
    label alabel "" pos:[10,10] width:90 height:16
    button updateBTN "Update label" pos:[10,25] width:80 height:16
    -- alabel.text = rolloutlabel as string
    -- this just gets a syntax error if i leave it here uncommented

    on rolloutDialog open do
    (
        alabel.text = rolloutlabel
    )


    on updateBTN pressed do
    (
        alabel.text = rolloutlabel
    )
)
createDialog rolloutDialog
于 2012-11-02T12:40:18.060 回答
0

您可以保留相同的脚本,但是您可以简单地编写 rolloutlabel,而不是 alabel 后的空双引号。脚本将如下所示:

rolloutlabel = "label"
rollout rolloutDialog "Rollout" width:100 height:50
(
    label alabel rolloutlabel pos:[10,10] width:90 height:16
    button updateBTN "Update label" pos:[10,25] width:80 height:16
    --alabel.text = (rolloutlabel as string)
    -- this just gets a syntax error if i leave it here uncommented
    on updateBTN pressed do
    (
        alabel.text = rolloutlabel
    )
)
createDialog rolloutDialog
于 2017-02-17T15:09:40.587 回答