Middle click on a tab closes it

This commit is contained in:
Thomas Brouard 2016-10-31 17:59:13 +01:00
parent 77e36dbffd
commit 9f50d55dcd

View file

@ -108,9 +108,8 @@ class Tab {
this.setIcon(this.iconURL); this.setIcon(this.iconURL);
this.setButtons(); this.setButtons();
tab.addEventListener("click", this.activate.bind(this), false); tab.addEventListener("click", this.tabClickHandler.bind(this), false);
this.tabGroup.tabContainer.appendChild(this.tab); this.tabGroup.tabContainer.appendChild(this.tab);
// TODO: handle middle click
} }
initWebview () { initWebview () {
@ -158,6 +157,14 @@ class Tab {
} }
} }
tabClickHandler (e) {
if (e.which === 1) {
this.activate();
} else if (e.which === 2) {
this.close();
}
}
activate () { activate () {
let activeTab = this.tabGroup.getActiveTab(); let activeTab = this.tabGroup.getActiveTab();
if (activeTab) { if (activeTab) {