HOME/END key support in lists
This commit is contained in:
parent
1cb811576b
commit
973e10fb8b
|
@ -60,6 +60,10 @@ function MenuView(options) {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.emitIndexUpdate = function() {
|
||||||
|
self.emit('index update', self.focusedItemIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
util.inherits(MenuView, View);
|
util.inherits(MenuView, View);
|
||||||
|
@ -174,19 +178,27 @@ MenuView.prototype.getItem = function(index) {
|
||||||
};
|
};
|
||||||
|
|
||||||
MenuView.prototype.focusNext = function() {
|
MenuView.prototype.focusNext = function() {
|
||||||
this.emit('index update', this.focusedItemIndex);
|
this.emitIndexUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
MenuView.prototype.focusPrevious = function() {
|
MenuView.prototype.focusPrevious = function() {
|
||||||
this.emit('index update', this.focusedItemIndex);
|
this.emitIndexUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
MenuView.prototype.focusNextPageItem = function() {
|
MenuView.prototype.focusNextPageItem = function() {
|
||||||
this.emit('index update', this.focusedItemIndex);
|
this.emitIndexUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
MenuView.prototype.focusPreviousPageItem = function() {
|
MenuView.prototype.focusPreviousPageItem = function() {
|
||||||
this.emit('index update', this.focusedItemIndex);
|
this.emitIndexUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
|
MenuView.prototype.focusFirst = function() {
|
||||||
|
this.emitIndexUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
|
MenuView.prototype.focusLast = function() {
|
||||||
|
this.emitIndexUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
MenuView.prototype.setFocusItemIndex = function(index) {
|
MenuView.prototype.setFocusItemIndex = function(index) {
|
||||||
|
|
|
@ -165,7 +165,6 @@ VerticalMenuView.prototype.setFocusItemIndex = function(index) {
|
||||||
};
|
};
|
||||||
|
|
||||||
VerticalMenuView.prototype.onKeyPress = function(ch, key) {
|
VerticalMenuView.prototype.onKeyPress = function(ch, key) {
|
||||||
|
|
||||||
if(key) {
|
if(key) {
|
||||||
if(this.isKeyMapped('up', key.name)) {
|
if(this.isKeyMapped('up', key.name)) {
|
||||||
this.focusPrevious();
|
this.focusPrevious();
|
||||||
|
@ -175,6 +174,10 @@ VerticalMenuView.prototype.onKeyPress = function(ch, key) {
|
||||||
this.focusPreviousPageItem();
|
this.focusPreviousPageItem();
|
||||||
} else if(this.isKeyMapped('page down', key.name)) {
|
} else if(this.isKeyMapped('page down', key.name)) {
|
||||||
this.focusNextPageItem();
|
this.focusNextPageItem();
|
||||||
|
} else if(this.isKeyMapped('home', key.name)) {
|
||||||
|
this.focusFirst();
|
||||||
|
} else if(this.isKeyMapped('end', key.name)) {
|
||||||
|
this.focusLast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,6 +311,16 @@ VerticalMenuView.prototype.focusNextPageItem = function() {
|
||||||
return VerticalMenuView.super_.prototype.focusNextPageItem.call(this);
|
return VerticalMenuView.super_.prototype.focusNextPageItem.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VerticalMenuView.prototype.focusFirst = function() {
|
||||||
|
this.setFocusItemIndex(0);
|
||||||
|
return VerticalMenuView.super_.prototype.focusFirst.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
VerticalMenuView.prototype.focusLast = function() {
|
||||||
|
this.setFocusItemIndex(this.items.length - 1);
|
||||||
|
return VerticalMenuView.super_.prototype.focusLast.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
VerticalMenuView.prototype.setFocusItems = function(items) {
|
VerticalMenuView.prototype.setFocusItems = function(items) {
|
||||||
VerticalMenuView.super_.prototype.setFocusItems.call(this, items);
|
VerticalMenuView.super_.prototype.setFocusItems.call(this, items);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue