diff --git a/build/bundle.js b/build/bundle.js index d4894cc6..e1215430 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -8872,7 +8872,6 @@ var init = function(){ // we always want to focus the text area to collect input var focusTextArea = function() { - console.log('focusing text area'); $('#commandTextField').focus(); }; focusTextArea(); @@ -8923,15 +8922,8 @@ function UI() { el: $('#commandLineHistory'), collection: this.commandCollection }); - - $('#commandTextField').focus(); - eventBaton.stealBaton('windowFocus', this.onWindowFocus, this); } -UI.prototype.onWindowFocus = function() { - this.commandPromptView.focus(); -}; - exports.getEvents = function() { return events; }; @@ -14211,7 +14203,6 @@ var MultiView = Backbone.View.extend({ // first we stop listening to keyboard and give that back to UI, which // other views will take if they need to this.keyboardListener.mute(); - require('../app').getEventBaton().releaseBaton('windowFocus', this.onWindowFocus, this); setTimeout(_.bind(function() { _.each(this.childViews, function(childView) { @@ -14224,7 +14215,6 @@ var MultiView = Backbone.View.extend({ start: function() { // steal the window focus baton - require('../app').getEventBaton().stealBaton('windowFocus', this.onWindowFocus, this); this.showViewIndex(this.currentIndex); }, @@ -14288,7 +14278,6 @@ var init = function(){ // we always want to focus the text area to collect input var focusTextArea = function() { - console.log('focusing text area'); $('#commandTextField').focus(); }; focusTextArea(); @@ -14339,15 +14328,8 @@ function UI() { el: $('#commandLineHistory'), collection: this.commandCollection }); - - $('#commandTextField').focus(); - eventBaton.stealBaton('windowFocus', this.onWindowFocus, this); } -UI.prototype.onWindowFocus = function() { - this.commandPromptView.focus(); -}; - exports.getEvents = function() { return events; }; @@ -17953,7 +17935,6 @@ var MultiView = Backbone.View.extend({ // first we stop listening to keyboard and give that back to UI, which // other views will take if they need to this.keyboardListener.mute(); - require('../app').getEventBaton().releaseBaton('windowFocus', this.onWindowFocus, this); setTimeout(_.bind(function() { _.each(this.childViews, function(childView) { @@ -17966,7 +17947,6 @@ var MultiView = Backbone.View.extend({ start: function() { // steal the window focus baton - require('../app').getEventBaton().stealBaton('windowFocus', this.onWindowFocus, this); this.showViewIndex(this.currentIndex); }, diff --git a/src/js/app/index.js b/src/js/app/index.js index 141ef413..966701bd 100644 --- a/src/js/app/index.js +++ b/src/js/app/index.js @@ -23,7 +23,6 @@ var init = function(){ // we always want to focus the text area to collect input var focusTextArea = function() { - console.log('focusing text area'); $('#commandTextField').focus(); }; focusTextArea(); @@ -74,15 +73,8 @@ function UI() { el: $('#commandLineHistory'), collection: this.commandCollection }); - - $('#commandTextField').focus(); - eventBaton.stealBaton('windowFocus', this.onWindowFocus, this); } -UI.prototype.onWindowFocus = function() { - this.commandPromptView.focus(); -}; - exports.getEvents = function() { return events; }; diff --git a/src/js/util/eventBaton.js b/src/js/util/eventBaton.js index be720f33..31595367 100644 --- a/src/js/util/eventBaton.js +++ b/src/js/util/eventBaton.js @@ -54,7 +54,7 @@ EventBaton.prototype.releaseBaton = function(name, func, context) { }, this); if (!found) { - throw new Error('did not find that function'); + throw new Error('did not find that function', func, context, name, arguments); } this.eventMap[name] = newListeners; }; diff --git a/src/js/views/index.js b/src/js/views/index.js index 5ea4ca9a..10032c20 100644 --- a/src/js/views/index.js +++ b/src/js/views/index.js @@ -126,11 +126,19 @@ var ModalView = Backbone.View.extend({ console.warn('stealing keyboard'); Main.getEventBaton().stealBaton('keydown', this.onKeyDown, this); Main.getEventBaton().stealBaton('keyup', this.onKeyUp, this); + Main.getEventBaton().stealBaton('windowFocus', this.onWindowFocus, this); + + $('#commandTextField').blur(); }, releaseKeyboard: function() { Main.getEventBaton().releaseBaton('keydown', this.onKeyDown, this); Main.getEventBaton().releaseBaton('keyup', this.onKeyUp, this); + Main.getEventBaton().releaseBaton('windowFocus', this.onWindowFocus, this); + }, + + onWindowFocus: function(e) { + console.log('window focus doing nothing', e); }, onKeyDown: function(e) { diff --git a/src/js/views/multiView.js b/src/js/views/multiView.js index 38afc220..ae8580d3 100644 --- a/src/js/views/multiView.js +++ b/src/js/views/multiView.js @@ -124,7 +124,6 @@ var MultiView = Backbone.View.extend({ // first we stop listening to keyboard and give that back to UI, which // other views will take if they need to this.keyboardListener.mute(); - require('../app').getEventBaton().releaseBaton('windowFocus', this.onWindowFocus, this); setTimeout(_.bind(function() { _.each(this.childViews, function(childView) { @@ -137,7 +136,6 @@ var MultiView = Backbone.View.extend({ start: function() { // steal the window focus baton - require('../app').getEventBaton().stealBaton('windowFocus', this.onWindowFocus, this); this.showViewIndex(this.currentIndex); }, diff --git a/todo.txt b/todo.txt index b1102fcb..69a8437c 100644 --- a/todo.txt +++ b/todo.txt @@ -12,7 +12,6 @@ Commands ======== [ ] move command creation outside of the command view so multiple things can be responsible for specifying the waterfall associated with a command! -[ ] then refactor keyboard input and UI.listen() to that event system [ ] multiple things can process!!! [ ] sip from buffer with post-command hooks. ideally the git engine knows nothing about the level being played @@ -35,6 +34,7 @@ Big Bugs to fix: Done things: (I only started this on Dec 17th 2012 to get a better sense of what was done) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +[x] then refactor keyboard input and UI.listen() to that event system [x] make some kind of "single listener" event system... will make keyboard stuff easy because then you just steal and release for modals and such [x] text input from the commandPromptView must flow down into