Package com.tonic.vellum.widget
Class TabHost
- java.lang.Object
-
- com.tonic.vellum.Section
-
- com.tonic.vellum.widget.TabHost
-
- All Implemented Interfaces:
FocusContainer
public final class TabHost extends Section implements FocusContainer
A tab container that renders the active tab's content plus a one-row tab bar. Children are retained across switches with only the visibility lifecycle firing, and the active content receives keys before the host's LEFT/RIGHT/CTRL_TAB switching.
-
-
Constructor Summary
Constructors Constructor Description TabHost()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intactive()SectionactiveFocusTarget()Returns the currently focused internal target.TabHostadd(java.lang.String title, Section content)Adds a tab with the given title and content.booleanadvanceFocus(boolean forward)Moves internal focus in the given direction.intcount()java.util.List<Section>focusTargets()Returns the focusable descendants this container manages internally.voidselect(int index)Switches to the tab at the given index, firing the visibility lifecycle on the outgoing and incoming children.voidselect(java.lang.String title)Switches to the tab with the given title.TabHostshowTabBar(boolean show)Sets whether the tab bar is shown.
-
-
-
Method Detail
-
add
public TabHost add(java.lang.String title, Section content)
Adds a tab with the given title and content.- Parameters:
title- the tab titlecontent- the tab content section- Returns:
- this TabHost for chaining
-
showTabBar
public TabHost showTabBar(boolean show)
Sets whether the tab bar is shown.- Parameters:
show-trueto show the tab bar- Returns:
- this TabHost for chaining
-
active
public int active()
- Returns:
- the active tab index
-
count
public int count()
- Returns:
- the tab count
-
select
public void select(int index)
Switches to the tab at the given index, firing the visibility lifecycle on the outgoing and incoming children. Out-of-range indices and the already-active index are ignored.- Parameters:
index- the tab index to activate
-
select
public void select(java.lang.String title)
Switches to the tab with the given title. Unknown titles are ignored.- Parameters:
title- the tab title to activate
-
focusTargets
public java.util.List<Section> focusTargets()
Description copied from interface:FocusContainerReturns the focusable descendants this container manages internally.- Specified by:
focusTargetsin interfaceFocusContainer- Returns:
- the focus targets, in traversal order
-
activeFocusTarget
public Section activeFocusTarget()
Description copied from interface:FocusContainerReturns the currently focused internal target.- Specified by:
activeFocusTargetin interfaceFocusContainer- Returns:
- the active focus target, or
nullwhen none is focused
-
advanceFocus
public boolean advanceFocus(boolean forward)
Description copied from interface:FocusContainerMoves internal focus in the given direction.- Specified by:
advanceFocusin interfaceFocusContainer- Parameters:
forward- true to advance, false to move back- Returns:
- true when focus moved internally, false at an edge so the parent advances instead
-
-