* VC.setFocus(): Attaches/detaches events/etc.
This commit is contained in:
parent
f348e06d86
commit
65ad2ffdd1
|
@ -426,7 +426,6 @@ function display(options, cb) {
|
|||
var generatedId = 100;
|
||||
|
||||
var cprListener = function(pos) {
|
||||
console.log(pos)
|
||||
if(mciPosQueue.length > 0) {
|
||||
var forMapItem = mciPosQueue.shift();
|
||||
mciMap[forMapItem].position = pos;
|
||||
|
@ -438,7 +437,6 @@ function display(options, cb) {
|
|||
};
|
||||
|
||||
function completed() {
|
||||
console.log('completed')
|
||||
options.client.removeListener('cursor position report', cprListener);
|
||||
parser.removeAllListeners(); // :TODO: Necessary???
|
||||
|
||||
|
@ -509,7 +507,6 @@ function display(options, cb) {
|
|||
|
||||
mciPosQueue.push(mapKey);
|
||||
|
||||
console.log('querying pos...')
|
||||
options.client.term.rawWrite(ansi.queryPos());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -37,9 +37,8 @@ function ViewController(options) {
|
|||
|
||||
this.clientKeyPressHandler = function(ch, key) {
|
||||
//
|
||||
// Process key presses treating form submit mapped
|
||||
// keys special. Everything else is forwarded on to
|
||||
// the focused View, if any.
|
||||
// Process key presses treating form submit mapped keys special.
|
||||
// Everything else is forwarded on to the focused View, if any.
|
||||
//
|
||||
if(key) {
|
||||
var submitViewId = self.submitKeyMap[key.name];
|
||||
|
@ -244,15 +243,17 @@ ViewController.prototype.getFocusedView = function() {
|
|||
return this.focusedView;
|
||||
};
|
||||
|
||||
ViewController.prototype.removeFocus = function() {
|
||||
var v = this.getFocusedView();
|
||||
if(v) {
|
||||
v.setFocus(false);
|
||||
this.focusedView = null;
|
||||
ViewController.prototype.setFocus = function(focused) {
|
||||
if(focused) {
|
||||
this.attachClientEvents();
|
||||
} else {
|
||||
this.detachClientEvents();
|
||||
}
|
||||
};
|
||||
|
||||
ViewController.prototype.switchFocus = function(id) {
|
||||
this.setFocus(true); // ensure events are attached
|
||||
|
||||
if(this.focusedView && this.focusedView.acceptsFocus) {
|
||||
this.switchFocusEvent('leave', this.focusedView);
|
||||
this.focusedView.setFocus(false);
|
||||
|
@ -488,7 +489,7 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) {
|
|||
confForFormId = formConfig.submit['*'];
|
||||
} else {
|
||||
// no configuration for this submitId
|
||||
delf.client.log.debug( { formId : formData.submitId }, 'No configuration for form ID');
|
||||
self.client.log.debug( { formId : formData.submitId }, 'No configuration for form ID');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ function FullScreenEditorModule(options) {
|
|||
self.updateTextEditMode(bodyView.getTextEditMode());
|
||||
self.updateEditModePosition(bodyView.getEditPosition());
|
||||
|
||||
self.viewControllers.body.removeFocus(); // :TODO: Change vc to allow *not* setting focus @ create
|
||||
self.viewControllers.body.setFocus(false);
|
||||
self.viewControllers.header.switchFocus(1);
|
||||
}
|
||||
);
|
||||
|
@ -234,7 +234,7 @@ function FullScreenEditorModule(options) {
|
|||
|
||||
this.menuMethods = {
|
||||
headerSubmit : function(formData, extraArgs) {
|
||||
self.viewControllers.header.removeFocus();
|
||||
self.viewControllers.header.setFocus(false);
|
||||
self.viewControllers.body.switchFocus(1);
|
||||
|
||||
self.getBodyView().on('edit position', function cursorPosUpdate(pos) {
|
||||
|
@ -253,7 +253,7 @@ function FullScreenEditorModule(options) {
|
|||
// :TODO:... what now?
|
||||
console.log(err)
|
||||
} else {
|
||||
self.viewControllers.body.removeFocus();
|
||||
self.viewControllers.body.setFocus(false);
|
||||
self.viewControllers.footerEditMenu.switchFocus(1);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue