setFocusItemIndex() support

This commit is contained in:
Bryan Ashby 2015-12-24 11:54:03 -07:00
parent a2011ef39c
commit d2c8bd90f0
3 changed files with 16 additions and 1 deletions

View File

@ -64,6 +64,12 @@ SpinnerMenuView.prototype.setFocus = function(focused) {
this.redraw(); this.redraw();
}; };
SpinnerMenuView.prototype.setFocusItemIndex = function(index) {
SpinnerMenuView.super_.prototype.setFocusItemIndex.call(this, index); // sets this.focusedItemIndex
this.updateSelection(); // will redraw
};
SpinnerMenuView.prototype.onKeyPress = function(ch, key) { SpinnerMenuView.prototype.onKeyPress = function(ch, key) {
if(key) { if(key) {
if(this.isKeyMapped('up', key.name)) { if(this.isKeyMapped('up', key.name)) {

View File

@ -89,6 +89,7 @@ function TextView(options) {
return this.position.col + offset; return this.position.col + offset;
}; };
// :TODO: Whatever needs init here should be done separately from setText() since it redraws/etc.
this.setText(options.text || ''); this.setText(options.text || '');
} }
@ -97,7 +98,9 @@ util.inherits(TextView, View);
TextView.prototype.redraw = function() { TextView.prototype.redraw = function() {
TextView.super_.prototype.redraw.call(this); TextView.super_.prototype.redraw.call(this);
if(_.isString(this.text)) {
this.drawText(this.text); this.drawText(this.text);
}
}; };
TextView.prototype.setFocus = function(focused) { TextView.prototype.setFocus = function(focused) {

View File

@ -146,6 +146,12 @@ VerticalMenuView.prototype.setFocus = function(focused) {
this.redraw(); this.redraw();
}; };
VerticalMenuView.prototype.setFocusItemIndex = function(index) {
VerticalMenuView.super_.prototype.setFocusItemIndex.call(this, index); // sets this.focusedItemIndex
this.redraw();
};
VerticalMenuView.prototype.onKeyPress = function(ch, key) { VerticalMenuView.prototype.onKeyPress = function(ch, key) {
if(key) { if(key) {