positioning test. fix screen key listening.

This commit is contained in:
Christopher Jeffrey 2013-06-11 09:20:09 -05:00
parent f463aa7b52
commit 8f4e23130e
2 changed files with 56 additions and 0 deletions

View File

@ -170,6 +170,13 @@ Screen._default = null;
Screen.prototype.__proto__ = Node.prototype;
Screen._addListener = Screen.prototype.addListener;
Screen.prototype.on =
Screen.prototype.addListener = function(type, listener) {
if (type === 'keypress') this._listenKeys();
return Screen._addListener.apply(this, arguments);
};
// TODO: Bubble events.
Screen.prototype._listenMouse = function(el, hover) {
var self = this;

49
test/widget-pos.js Normal file
View File

@ -0,0 +1,49 @@
var blessed = require('blessed')
, program = blessed();
var screen = new blessed.Screen({
program: program
});
var main = new blessed.Box({
width: '75%',
height: '75%',
bg: 3,
top: 2,
left: 2,
content: 'Welcome to my program'
});
screen.append(main);
var inner = new blessed.Box({
width: '50%',
height: '50%',
bg: 4,
top: 2,
left: 2,
content: 'Hello'
});
main.append(inner);
inner.setContent(inner.content + '\n' + JSON.stringify({
left: inner.left,
right: inner.right,
top: inner.top,
bottom: inner.bottom,
width: inner.width,
height: inner.height,
rleft: inner.rleft,
rright: inner.rright,
rtop: inner.rtop,
rbottom: inner.rbottom
}));
screen.on('keypress', function(ch, key) {
if (key.name === 'escape' || key.name === 'q') {
return process.exit(0);
}
});
screen.render();