如何动态地将新标签页添加到红色标签页中

如何动态地将新标签页添加到红色标签页中

问题描述:

假设您有一个这样的标签面板:

Let's say you have a tab-panel like so :

editor: layout [
    below
    t: tab-panel 350x350 [
        "tab 1" [
            below
            b: button 75x25 "Interpret" on-click [do a/text ]
            a: area 320x250
        ]
    ]
]

view editor

如何动态地向其添加新标签,使其具有当前标签的内容?

How could I dynamically add a new tab to it so that has the contents of the current tab?

它们是动态添加新标签的几种方法,但是在所有情况下,归结为添加:

They are several ways to add a new tab dynamically, but in all cases, it boils down to adding:

  • 制表符标签,作为string!t/data块.
  • t/pane块相对应的panelobject!.
  • A tab label as a string! to t/data block.
  • A corresponding panel face object! to t/pane block.

这是一个完全正常的示例代码:

Here is a fully working example code:

tab1: [
    below
    button 75x25 "Interpret" on-click [do face/parent/pane/2/text ]
    area 320x250
]

editor: layout compose/deep/only [
    below
    button "add tab" [
        append t/data "tab 2"
        append t/pane make face! [type: 'panel pane: layout/only tab1]
    ]
    t: tab-panel 350x350 ["tab 1" (tab1)]
]
view editor

一些评论:

  • tab1定义已被外部化,因此可以将其定义用于其他选项卡内容(根据您的要求).
  • a:单词已被删除,因为它无法重复,现在可以通过在脸部树上行走来访问当前选项卡面板中的当前area脸部. b:定义由于相同的原因而被删除(无论如何也未使用).
  • tab1 definition has been externalized, so its definition can be reused for another tab content (as per your request).
  • a: word has been removed as it cannot be duplicated, access to the current area face in current tab panel is now done by walking up the face tree. b: definition has been dropped for same reason (and it's not used anyway).

有关动态行为和动态面部构造(不使用VID方言)的示例,请参见.

Examples of dynamic behaviors and dynamic face construction (without VID dialect) are available here. tab-panel face type is described there.