3

我正在尝试在查看后将字段添加到布局

view/no-wait m: [field "hello"]
insert tail m 'field
insert tail m "hello"
update-face m
** Script error: update-face does not allow block! for its face argument

我想更新整个布局,而不仅仅是字段或其中的一部分。如果我尝试使用 view m,它会打开一个新窗口。我只需要取消查看然后再查看吗?

4

3 回答 3

6

您也可以在 R3-GUI 中使用 LAYOUT 功能。请参见下面的示例:

view/no-wait m: layout [field "hello"]

;We need to get the BACKDROP container which is first sub-face in the WINDOW face
m: first faces? m

append-content m [
    field "world"
]

do-events

当然还有其他方法可以动态处理布局内容。

于 2013-07-29T09:05:34.517 回答
1

试试理查德的这个例子

REBOL [
    Title: "Layouts example #20"
    Author: "Richard Smolak"
    Version: "$Id: layouts-20.r3 852 2010-10-07 13:28:26Z cyphre $"
]

stylize [

    tbox: hpanel [

        about: "Simple rectangular box."

        facets: [
            init-hint: 200x200
            min-hint: 0x0
            max-hint: guie/max-pair
            break-after: 1
        ]

        options: [
            init-hint: [pair!]
        ]

        actors: [
            on-make: [
                append face/options [
                    content: [
                        button "hello" on-action [print "hello"]
                        button "world" on-action [print "hello"]
                    ]
                ]
                do-actor/style face 'on-make none 'hpanel
            ]
        ]

        draw: [
            pen red
            fill-pen blue
            box 0x0 (viewport-box/bottom-right - 1)
        ]
    ]
]


view [
    test: tbox
    button "clear"
        on-action [
            clear-content test
        ]   
    button "set"
        on-action [
            set-content test [
                button "test"
                field "the best"
            ]
        ]   
    button "insert"
        on-action [
            insert-content test bind/set probe reduce [to-set-word copy/part random "abcdefgh" 2 'button join "button #" 1 + length? test/gob] 'system
        ]
    button "append"
        on-action [
            append-content test reduce ['button join "button #" 1 + length? test/gob]
        ]   
    button "remove 2 faces at pos 3"
        on-action [
            remove-content/pos/part test 3 2
        ]
]

因此,您要查找的单词是append-content,并且insert-content将人脸和块作为参数,其中块包含另一张脸的定义。

于 2013-07-29T07:02:10.883 回答
0

我还不知道视图,但我有一个提示。第一行将“m”设置为块 [field “hello”]。检查以查看“update-face”的期望...

于 2013-07-26T16:07:07.323 回答