2014-10-23 22:40:52 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var TextView = require('./text_view.js').TextView;
|
2014-10-24 04:18:38 +00:00
|
|
|
var miscUtil = require('./misc_util.js');
|
2014-10-23 22:40:52 +00:00
|
|
|
var util = require('util');
|
|
|
|
var assert = require('assert');
|
|
|
|
|
2014-10-24 04:18:38 +00:00
|
|
|
exports.ButtonView = ButtonView;
|
|
|
|
|
2014-10-23 22:40:52 +00:00
|
|
|
function ButtonView(client, options) {
|
|
|
|
options.acceptsFocus = miscUtil.valueWithDefault(options.acceptsFocus, true);
|
|
|
|
options.acceptsInput = miscUtil.valueWithDefault(options.acceptsInput, true);
|
|
|
|
|
|
|
|
TextView.call(this, client, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
util.inherits(ButtonView, TextView);
|
|
|
|
|
|
|
|
ButtonView.prototype.onKeyPress = function(key, isSpecial) {
|
2014-10-24 04:18:38 +00:00
|
|
|
ButtonView.super_.prototype.onKeyPress.call(this, key, isSpecial);
|
2014-10-23 22:40:52 +00:00
|
|
|
|
2014-10-24 04:18:38 +00:00
|
|
|
// allow spacebar to 'click' buttons
|
|
|
|
if(' ' === key) {
|
|
|
|
this.emit('action', 'accept');
|
|
|
|
}
|
|
|
|
};
|