expose enableMouse, enableKeys, and enableInput.

This commit is contained in:
Christopher Jeffrey 2015-02-24 18:33:00 -08:00
parent 02fd115fb0
commit 3778c37f40
2 changed files with 32 additions and 0 deletions

View File

@ -269,6 +269,9 @@ The screen on which every other node renders.
- **insertTop(top, bottom)** - insert a line at the top of the screen.
- **deleteBottom(top, bottom)** - delete a line at the bottom of the screen.
- **deleteTop(top, bottom)** - delete a line at the top of the screen.
- **enableMouse([el])** - enable mouse events for the screen and optionally an element (automatically called when a form of on('mouse') is bound).
- **enableKeys([el])** - enable keypress events for the screen and optionally an element (automatically called when a form of on('keypress') is bound).
- **enableInput([el])** - enable key and mouse events. calls bot enableMouse and enableKeys.
#### Element (from Node)
@ -391,6 +394,9 @@ The base element.
- **setHover(text/options)** - set the hover text for the bottom-right corner.
example options: `{text:'foo'}`
- **removeHover()** - remove the hover label completely.
- **enableMouse()** - enable mouse events for the element (automatically called when a form of on('mouse') is bound).
- **enableKeys()** - enable keypress events for the element (automatically called when a form of on('keypress') is bound).
- **enableInput()** - enable key and mouse events. calls bot enableMouse and enableKeys.
###### Content Methods

View File

@ -588,6 +588,10 @@ Screen.prototype._listenMouse = function(el) {
});
};
Screen.prototype.enableMouse = function(el) {
this._listenMouse(el);
};
Screen.prototype._listenKeys = function(el) {
var self = this;
@ -631,6 +635,15 @@ Screen.prototype._listenKeys = function(el) {
});
};
Screen.prototype.enableKeys = function(el) {
this._listenKeys(el);
};
Screen.prototype.enableInput = function(el) {
this._listenMouse(el);
this._listenKeys(el);
};
Screen.prototype.__defineGetter__('cols', function() {
return this.program.cols;
});
@ -2420,6 +2433,19 @@ Element.prototype.__defineGetter__('_detached', function() {
return false;
});
Element.prototype.enableMouse = function() {
this.screen._listenMouse(this);
};
Element.prototype.enableKeys = function() {
this.screen._listenKeys(this);
};
Element.prototype.enableInput = function() {
this.screen._listenMouse(this);
this.screen._listenKeys(this);
};
Element.prototype.key = function() {
return this.screen.program.key.apply(this, arguments);
};