如何动态地将新标签页添加到红色标签页中 [英] How can you dynamically add a new tab to a tab-panel in Red

查看:109
本文介绍了如何动态地将新标签页添加到红色标签页中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于如何动态地将新标签页添加到红色标签页中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆