Skip to content

Instantly share code, notes, and snippets.

Created January 5, 2013 00:54
Show Gist options
  • Save anonymous/4458914 to your computer and use it in GitHub Desktop.
Save anonymous/4458914 to your computer and use it in GitHub Desktop.
QooxDoo TabView extension to implement mousewheel reaction
qx.Class.define("qx.ui.tabview.TabView", {
extend: qx.ui.tabview.TabView,
members: {
// Select next tab
next: function () {
var size = this.getSelectables().length;
var idx = this.getSelectables().indexOf(this.getSelection()[0]);
if (idx < size - 1) {
this.setSelection([this.getSelectables()[idx + 1]]);
};
},
// Select previous tab
previous: function () {
var idx = this.getSelectables().indexOf(this.getSelection()[0]);
if (idx > 0) {
this.setSelection([this.getSelectables()[idx - 1]]);
};
},
// Enable mousewheel reaction
mousewheelReaction: function () {
this.getChildControl("bar").addListener("mousewheel", function (e) {
if (e.getWheelDelta() < 0) {
this.previous();
} else {
this.next();
};
// stop the propagation
// prevent any other widget from receiving this event
// e.g. place a selectbox widget inside a scroll container widget
e.stopPropagation();
e.preventDefault();
}, this);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment