* Use more standard code paths & emit index events in ToggleMenuView

* Fix fetching areas & internal message attach area name
* Use proper config in new MenuModule methods
* More good progress on uploading
This commit is contained in:
Bryan Ashby 2017-01-01 21:53:04 -07:00
parent 0a92eec5e8
commit a45142f2fd
7 changed files with 205 additions and 45 deletions

View file

@ -25,9 +25,7 @@ function ToggleMenuView (options) {
*/
this.updateSelection = function() {
//assert(!self.positionCacheExpired);
assert(this.focusedItemIndex >= 0 && this.focusedItemIndex <= self.items.length);
self.redraw();
};
}
@ -74,28 +72,38 @@ ToggleMenuView.prototype.setFocus = function(focused) {
this.redraw();
};
ToggleMenuView.prototype.onKeyPress = function(ch, key) {
if(key) {
var needsUpdate;
if(this.isKeyMapped('right', key.name) || this.isKeyMapped('down', key.name)) {
if(this.items.length - 1 === this.focusedItemIndex) {
this.focusedItemIndex = 0;
} else {
this.focusedItemIndex++;
}
needsUpdate = true;
} else if(this.isKeyMapped('left', key.name) || this.isKeyMapped('up', key.name)) {
if(0 === this.focusedItemIndex) {
this.focusedItemIndex = this.items.length - 1;
} else {
this.focusedItemIndex--;
}
needsUpdate = true;
}
ToggleMenuView.prototype.focusNext = function() {
if(this.items.length - 1 === this.focusedItemIndex) {
this.focusedItemIndex = 0;
} else {
this.focusedItemIndex++;
}
if(needsUpdate) {
this.updateSelection();
return;
this.updateSelection();
ToggleMenuView.super_.prototype.focusNext.call(this);
};
ToggleMenuView.prototype.focusPrevious = function() {
if(0 === this.focusedItemIndex) {
this.focusedItemIndex = this.items.length - 1;
} else {
this.focusedItemIndex--;
}
this.updateSelection();
ToggleMenuView.super_.prototype.focusPrevious.call(this);
};
ToggleMenuView.prototype.onKeyPress = function(ch, key) {
if(key) {
if(this.isKeyMapped('right', key.name) || this.isKeyMapped('down', key.name)) {
this.focusNext();
} else if(this.isKeyMapped('left', key.name) || this.isKeyMapped('up', key.nam4e)) {
this.focusPrevious();
}
}