【问题标题】:REBOL 3 - How to update a layout that has already been viewed?REBOL 3 - 如何更新已查看的布局?
【发布时间】:2013-07-26 15:44:25
【问题描述】:

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

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,它会打开一个新窗口。我只需要取消查看然后再查看吗?

【问题讨论】:

    标签: rebol rebol3 r3-gui


    【解决方案1】:

    您也可以在 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
    

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

    【讨论】:

      【解决方案2】:

      试试 Richard 的这个例子

      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-contentinsert-content,它们将面和块作为参数,其中块包含另一个面的定义。

      【讨论】:

        【解决方案3】:

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

        【讨论】:

        • 我知道 m 是一个块。在 R2 中,这将是 m: layout [field "hello"],这对于我正在做的事情来说可以。我不确定这在 R3 中是如何发生的。我知道update-face 需要一个人脸对象
        • 我想我可以在 R3 中以同样的方式使用 layout 词,但是有没有办法在布局中插入新词?
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-12-27
        • 1970-01-01
        • 2014-12-21
        • 2011-08-19
        • 2016-09-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多