Add keyboard shortcuts for tabs

This commit is contained in:
Zack Rauen
2023-09-08 22:53:21 -04:00
parent c881b39860
commit 15254e2dfc
2 changed files with 80 additions and 0 deletions

View File

@@ -267,8 +267,28 @@ export default class TabRowWidget extends BasicWidget {
}
});
});
keyboardActionService.setupActionsForElement('tabs', $(document), this);
}
goToTab(tabNumber) {
const index = tabNumber === 0 ? this.tabEls.length - 1 : tabNumber - 1;
const tab = this.tabEls[index];
if (!tab) return;
appContext.tabManager.activateNoteContext(tab.getAttribute('data-ntx-id'));
}
firstTabCommand() {this.goToTab(1);}
secondTabCommand() {this.goToTab(2);}
thirdTabCommand() {this.goToTab(3);}
fourthTabCommand() {this.goToTab(4);}
fifthTabCommand() {this.goToTab(5);}
sixthTabCommand() {this.goToTab(6);}
seventhTabCommand() {this.goToTab(7);}
eigthTabCommand() {this.goToTab(8);}
ninthTabCommand() {this.goToTab(9);}
lastTabCommand() {this.goToTab(0);}
setupStyle() {
this.$style = $("<style>");
this.$widget.append(this.$style);