Project

General

Profile

Wt::WTabWidget -> setCurrentIndex

Added by T Y about 9 years ago

Hi,

Great work. I love and use it.

I am seeking feedback on WTabWidget::setCurrentIndex

When using with Wt 3.3.4 and Bootstrap2 -> Tab set as active programmatically is not rendered as selected.

It looks like setCurrentIndex assigns to selected tab class itemselected.

When selection of tab is performed through clicking tab -> active tab has class "item active".

My workaround is to add to active tab style class "active". For this when adding tabs I am keeping references in array:

Wt::WTabWidget *pTabWidget = new Wt::WTabWidget();

std::vector<Wt::WMenuItem *> aMenuItems;

aMenuItems.push_back(pTabWidget->addTab(new Wt::WText("Tab1 body"), "Tab1"));
aMenuItems.push_back(pTabWidget->addTab(new Wt::WText("Tab2 body"), "Tab2"));
aMenuItems.push_back(pTabWidget->addTab(new Wt::WText("Tab3 body"), "Tab3"));

pTabWidget->setCurrentItem(1); // Select 2nd tab programmatically
aMenuItems.at(1)->addStyleClass("active"); // Force to render Tab2 as active

Any feedback is welcome.

Thank you.

Kind regards,

TY