Skip to main content

ButtonTabBar (버튼탭바) Widget Control

info

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.

info

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.

note

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 ControlKindSignatureDescription
setTabsMethodsetTabs(tabs): voidReplaces every tab with the given list
addMethodadd(tab): voidAdds one tab at the end
changeTabMethodchangeTab(index, tab): voidReplaces the tab at a specific position
getTextMethodgetText(index): stringReturns the label text of that tab
indexPropertynumber (Read/write)Index of the currently selected tab
onChangedEventonChanged = (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 replace
    • tab: 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)

note

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.