ButtonTabBar (버튼탭바) Widget Control
Example file: 07_Work_with_Widgets/tabbar_buttontabbar_objet.lfp
This page lists the Widget Controls (Property · Method · Event) you use to control the ButtonTabBar widget from a script. To learn about the widget itself and how to use it, visit ButtonTabBar.
In the examples below, buttontabbarID is the name (ID) you gave the ButtonTabBar widget on the canvas. In a script, you access it as widgetID.member.
ButtonTabBar's Widget Controls are identical to TabBar's — only the appearance is button-style. The difference lies in how you use it (its properties).
Widget Control summary
| Widget Control | Kind | Signature | Description |
|---|---|---|---|
setTabs | Method | setTabs(tabs): void | Replaces every tab with the given list |
add | Method | add(tab): void | Adds one tab at the end |
changeTab | Method | changeTab(index, tab): void | Replaces the tab at a specific position |
getText | Method | getText(index): string | Returns the label text of that tab |
index | Property | number (Read/write) | Index of the currently selected tab |
onChanged | Event | onChanged = (index) => { ... } | Runs when the selected tab changes |
Property
index
The index of the currently selected tab, starting at 0. Write a value to switch to that tab.
- Type:
number - Access: Read/write
Example
buttontabbarID.index = 1;
const current = buttontabbarID.index;
Method
add
Adds one tab to the end of the list.
- Parameters
tab: The tab definition (its label text)
- Returns: None (
void)
Example
buttontabbarID.add("Settings");
setTabs
Replaces every tab with the given list. An empty list is ignored.
- Parameters
tabs: The list of tabs
- Returns: None (
void)
Example
buttontabbarID.setTabs(["Home", "Chart", "Settings"]);
changeTab
Replaces the tab at the given position (index). An index outside the valid range is ignored.
- Parameters
index(number): The position of the tab to replacetab: The new tab definition (its label text)
- Returns: None (
void)
Example
//Replace the tab at index 1 with 'Chart'
buttontabbarID.changeTab(1, "Chart");
getText
Returns the label text of the tab at the given index. If the index is outside the valid range, it returns an empty string ('').
- Parameters
index(number): The position of the tab to read
- Returns:
string- the tab's label text (''if out of range)
Example
const label = buttontabbarID.getText(0);
Event
onChanged
Runs when the selected tab changes.
- Kind: Event
- Handler arguments
index(number): The index of the newly selected tab
- Returns: None
Example
buttontabbarID.onChanged = (index) => {
// index: the index of the newly selected tab
};
Common Widget Control (all widgets)
Every widget can also use common Widget Controls (Method) such as setProperty(name, value) / getProperty(name) / setStyleProperty(styleName, styleProperty, value). For the detailed rules, see the common Widget Control reference.