improv: return the index of the last added tab (#405)

* widgets(tabs): return the index of the last added tab

* widgets(tabs): returning the index of the newly added tab

* demo: using the tab component in the demo to verify

* lint: fixing lint
This commit is contained in:
Shubham Zanwar 2020-02-20 13:02:44 +05:30 committed by GitHub
parent cf7d241b51
commit 5415fa3576
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -65,9 +65,10 @@ Napi::Value QTabWidgetWrap::addTab(const Napi::CallbackInfo& info) {
Napi::ObjectWrap<QWidgetWrap>::Unwrap(pageObject);
QIconWrap* iconWrap = Napi::ObjectWrap<QIconWrap>::Unwrap(iconObject);
this->instance->addTab(pageObjectWrap->getInternalInstance(),
*iconWrap->getInternalInstance(), label.c_str());
return env.Null();
int index =
this->instance->addTab(pageObjectWrap->getInternalInstance(),
*iconWrap->getInternalInstance(), label.c_str());
return Napi::Number::New(env, index);
}
Napi::Value QTabWidgetWrap::setTabPosition(const Napi::CallbackInfo& info) {

View File

@ -42,10 +42,11 @@ export class QTabWidget extends NodeWidget<QTabWidgetSignals> {
this.native = native;
}
addTab(page: NodeWidget<any>, icon: QIcon, label: string): void {
this.native.addTab(page.native, icon.native, label);
addTab(page: NodeWidget<any>, icon: QIcon, label: string): number {
const index = this.native.addTab(page.native, icon.native, label);
this.tabs.push(page);
page.setFlexNodeSizeControlled(true);
return index;
}
setTabPosition(tabPosition: TabPosition): void {