diff --git a/core/fse--class.js b/core/fse--class.js index c2b09fb2..a6daa0e3 100644 --- a/core/fse--class.js +++ b/core/fse--class.js @@ -270,10 +270,18 @@ function FullScreenEditor(options) { }; this.initObservers = function() { + // :TODO: Should probably still allow key mapping/etc. to come from module for this stuff + this.viewControllers.header.on('submit', function headerSubmit(formData, extraArgs) { - if(formData.id === self.getFormId('header')) { - self.viewControllers.header.setFocus(false); - self.viewControllers.body.switchFocus(1); + // :TODO: we need to validate the "to" here + self.viewControllers.header.setFocus(false); + self.viewControllers.body.switchFocus(1); + }); + + this.viewControllers.body.on('submit', function bodySubmit(formData, extraArgs) { + + if(formData.key && 'escape' === formData.key.name) { + console.log('toggle menu depending on mode...') } }); }; diff --git a/core/multi_line_edit_text_view.js b/core/multi_line_edit_text_view.js index bf0c9e78..b0590882 100644 --- a/core/multi_line_edit_text_view.js +++ b/core/multi_line_edit_text_view.js @@ -108,7 +108,7 @@ function MultiLineEditTextView(options) { // this.tabWidth = _.isNumber(options.tabWidth) ? options.tabWidth : 4; - this.textLines = []; + this.textLines = [ ]; this.topVisibleIndex = 0; this.mode = options.mode || 'edit'; // edit | preview | read-only @@ -1013,6 +1013,8 @@ function MultiLineEditTextView(options) { self.overtypeMode = !self.overtypeMode; self.emit('text edit mode', self.getTextEditMode()); }; + + this.insertRawText(''); // init to blank/empty } require('util').inherits(MultiLineEditTextView, View); diff --git a/core/view.js b/core/view.js index f2ae6306..90499d01 100644 --- a/core/view.js +++ b/core/view.js @@ -254,9 +254,9 @@ View.prototype.onKeyPress = function(ch, key) { assert(this.specialKeyMap, 'No special key map defined'); if(this.isKeyMapped('accept', key.name)) { - this.emit('action', 'accept'); + this.emit('action', 'accept', key); } else if(this.isKeyMapped('next', key.name)) { - this.emit('action', 'next'); + this.emit('action', 'next', key); } } diff --git a/core/view_controller.js b/core/view_controller.js index a3163791..d608846e 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -50,7 +50,7 @@ function ViewController(options) { // Key works on behalf of a view -- switch focus & submit // self.switchFocus(actionForKey); - self.submitForm(); + self.submitForm(key); } else if(_.isString(actionForKey)) { // :TODO: Populate formData here? // :TODO: Populate actionBlock here -- that is, the actionKey entry... or @@ -67,16 +67,16 @@ function ViewController(options) { } }; - this.viewActionListener = function(action) { + this.viewActionListener = function(action, key) { switch(action) { case 'next' : - self.emit('action', { view : this, action : action }); + self.emit('action', { view : this, action : action, key : key } ); self.nextFocus(); break; case 'accept' : if(self.focusedView && self.focusedView.submit) { - self.submitForm(); + self.submitForm(key); } else { self.nextFocus(); } @@ -84,8 +84,8 @@ function ViewController(options) { } }; - this.submitForm = function() { - self.emit('submit', this.getFormData()); + this.submitForm = function(key) { + self.emit('submit', this.getFormData(key)); }; this.getLogFriendlyFormData = function(formData) { @@ -716,12 +716,13 @@ ViewController.prototype.formatMCIString = function(format) { }); }; -ViewController.prototype.getFormData = function() { +ViewController.prototype.getFormData = function(key) { /* Example form data: { id : 0, submitId : 1, + key : { ... }, // optional key that triggered submit value : { "1" : "hurp", "2" : [ 'a', 'b', ... ], @@ -737,6 +738,10 @@ ViewController.prototype.getFormData = function() { value : {}, }; + if(_.isObject(key)) { + formData.key = key; + } + var viewData; var view; for(var id in this.views) { @@ -756,7 +761,7 @@ ViewController.prototype.getFormData = function() { } return formData; -} +}; /* ViewController.prototype.formatMenuArgs = function(args) { diff --git a/mods/menu.json b/mods/menu.json index 4655df84..31b676a5 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -309,6 +309,33 @@ ] }*/ } + }, + "1" : { + "MT" : { + "mci" : { + "MT1" : { + "width" : 79, + "height" : 17, + //"text" : "", // :TODO: should not be req. + "argName" : "message" + } + },/*, + "submit" : { + "*" : [ + { + "value" : "message", + "action" : "@method:editModeEscPressed" + } + ] + }, + */ + "actionKeys" : [ + { + "keys" : [ "escape" ], + "viewId" : 1 + } + ] + } } } },