Detecting when main window tabs are selected

Hello,

I’ve encountered a problem with the Main Window Tabsheet. Let’s say i have a side menu component named Dashboard. If i press click on the dashboard menu item it opens the dashboard window in a new tab. Than I have a second Dashboard menu item and i open it too. So now i have in my MainWindow 2 tabs. One with the first dashboard, and one with the second dashboard. The selected tab is dashboard number 2. I need an event when I press on the dashboard 1 tab (i need to acces somehow the main tabsheet onselecttab listener or something like that).

I didn’t manage to find any solutions…

Hello @eugen.vlasie

You can extend the main window and add tab change listener to track selection:

HasTabSheetBehaviour tabbedContainer = ((WebAppWorkArea) workArea).getTabbedWindowContainer();

if (webConfig.getMainTabSheetMode() == MainTabSheetMode.DEFAULT) {
    ((CubaTabSheet) tabbedContainer).addSelectedTabChangeListener(e -> {
        // your code here
    });
} else {
    ((CubaManagedTabSheet) tabbedContainer).addSelectedTabChangeListener(e -> {
        // your code here
    });
}

Regards,
Daniil.