mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-30 14:36:19 +02:00
* Better view inheritance. Experimental ButtonView. User stuff
This commit is contained in:
parent
8cd062be72
commit
668fdd9166
8 changed files with 171 additions and 202 deletions
|
@ -2,9 +2,12 @@
|
|||
'use strict';
|
||||
|
||||
var TextView = require('./text_view.js').TextView;
|
||||
var miscUtil = require('./misc_util.js');
|
||||
var util = require('util');
|
||||
var assert = require('assert');
|
||||
|
||||
exports.ButtonView = ButtonView;
|
||||
|
||||
function ButtonView(client, options) {
|
||||
options.acceptsFocus = miscUtil.valueWithDefault(options.acceptsFocus, true);
|
||||
options.acceptsInput = miscUtil.valueWithDefault(options.acceptsInput, true);
|
||||
|
@ -15,15 +18,10 @@ function ButtonView(client, options) {
|
|||
util.inherits(ButtonView, TextView);
|
||||
|
||||
ButtonView.prototype.onKeyPress = function(key, isSpecial) {
|
||||
// we accept input so this must be implemented -- nothing to do here, however
|
||||
// :TODO: Move this to View along with default asserts; update EditTextView to call View
|
||||
}
|
||||
ButtonView.super_.prototype.onKeyPress.call(this, key, isSpecial);
|
||||
|
||||
ButtonView.prototype.onSpecialKeyPress = function(keyName) {
|
||||
assert(this.hasFocus);
|
||||
assert(this.acceptsInput);
|
||||
assert(this.specialKeyMap);
|
||||
|
||||
// :TODO: see notes about making base handle 'enter' key(s)
|
||||
// ...just make enter = enter | space for a button by default
|
||||
}
|
||||
// allow spacebar to 'click' buttons
|
||||
if(' ' === key) {
|
||||
this.emit('action', 'accept');
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue