tabsheet ... shit :-)

hi vaadiners

i have some issue with TabSheet, i add 2 tabs, tab1 & tab2 and when i click on tab2 tab bar, tabsheet.getTabIndex() still return 0 (i expected 1) , what i missed ? i just want the index clicked on the tab bar, how can retrieve this index ?




Use getTabPosition().

The getTabIndex() is rather easily misleading in TabSheet, as it has nothing to do with TabSheet tabs, but keyboard focus tabs. When you press the Tab key on the keyboard, it moves focus from one component to another. The tab index is used to control the focus sequence when pressing the Tab key. It’s defined in the Component.Focusable interface.

thx Marko but getTabPosition need one tab arg, why do not propose this simple api ?
i have to code these lines pour each tab events:

    HorizontalSplitPanel tab = (HorizontalSplitPanel) tabsheet.getSelectedTab();
   FormLayout editorLayout = editorLayouts.get(tabsheet.getTabPosition(tabsheet.getTab(tab)));


You should be able to say that in one line, but yes, it’s a bit complex.

FormLayout editorLayout = editorLayouts.get(tabsheet.getTabPosition(tabsheet.getTab(tabsheet.getSelectedTab())));

I guess a getTabPosition(Component) might be reasonable to have in addition to the getTabPosition(Tab). The Tab objects are not Components, so it should not be a problem.