2014-10-23 22:40:52 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
2017-02-08 03:14:56 +00:00
|
|
|
const TextView = require('./text_view.js').TextView;
|
|
|
|
const miscUtil = require('./misc_util.js');
|
|
|
|
const util = require('util');
|
2014-10-23 22:40:52 +00:00
|
|
|
|
2014-10-24 04:18:38 +00:00
|
|
|
exports.ButtonView = ButtonView;
|
|
|
|
|
2015-04-09 04:54:13 +00:00
|
|
|
function ButtonView(options) {
|
2014-11-03 23:49:15 +00:00
|
|
|
options.acceptsFocus = miscUtil.valueWithDefault(options.acceptsFocus, true);
|
|
|
|
options.acceptsInput = miscUtil.valueWithDefault(options.acceptsInput, true);
|
|
|
|
options.justify = miscUtil.valueWithDefault(options.justify, 'center');
|
2015-04-09 04:54:13 +00:00
|
|
|
options.cursor = miscUtil.valueWithDefault(options.cursor, 'hide');
|
2014-10-23 22:40:52 +00:00
|
|
|
|
2015-04-09 04:54:13 +00:00
|
|
|
TextView.call(this, options);
|
2014-10-23 22:40:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
util.inherits(ButtonView, TextView);
|
|
|
|
|
2015-06-06 06:33:59 +00:00
|
|
|
ButtonView.prototype.onKeyPress = function(ch, key) {
|
2017-02-08 03:14:56 +00:00
|
|
|
// allow space = submit
|
|
|
|
if(' ' === ch) {
|
2014-10-24 04:18:38 +00:00
|
|
|
this.emit('action', 'accept');
|
|
|
|
}
|
2015-06-06 06:33:59 +00:00
|
|
|
|
|
|
|
ButtonView.super_.prototype.onKeyPress.call(this, ch, key);
|
2015-03-31 03:29:06 +00:00
|
|
|
};
|
|
|
|
|
2015-04-17 04:29:53 +00:00
|
|
|
ButtonView.prototype.getData = function() {
|
2015-03-31 03:29:06 +00:00
|
|
|
return null;
|
|
|
|
};
|