2013-07-26 47 views
3

我想要一個字段添加到佈局已經看到REBOL 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,它會打開一個新窗口。我是否必須取消查看,然後再查看?

回答

5

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

Ofcourse也有其他的方式如何動態地處理版面內容。

0

我還不知道,但我有一個提示。第一行將「m」設置爲塊[field「hello」]。檢查,看看有什麼「更新臉」預計...

+0

我知道m是一個塊。在R2中,這將是'm:layout [field「hello」]'這對我正在做的事情可以正常工作。我不確定R3會如何發生。我知道'update-face'需要一個臉部對象 – kealist

+0

我想我可以在R3中使用'layout'字樣,但是有沒有辦法將新單詞插入到佈局中? – kealist

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-contentinsert-content內搭了個鬼臉,作爲參數塊塊包含另一個面的定義。