Show More
@@ -288,8 +288,16 b' var IPython = (function (IPython) {' | |||
|
288 | 288 | * @method focus_editor |
|
289 | 289 | */ |
|
290 | 290 | Cell.prototype.focus_editor = function () { |
|
291 | var that = this; | |
|
291 | 292 | this.refresh(); |
|
292 | this.code_mirror.focus(); | |
|
293 | // Only focus the CM editor if it is not focused already. This prevents jumps | |
|
294 | // related to the previous prompt position. | |
|
295 | setTimeout(function () { | |
|
296 | var isf = IPython.utils.is_focused; | |
|
297 | if (!isf(that.element.find('div.CodeMirror'))) { | |
|
298 | that.code_mirror.focus(); | |
|
299 | } | |
|
300 | }, 1); | |
|
293 | 301 | } |
|
294 | 302 | |
|
295 | 303 | /** |
@@ -740,18 +740,15 b' var IPython = (function (IPython) {' | |||
|
740 | 740 | KeyboardManager.prototype.register_events = function (e) { |
|
741 | 741 | var that = this; |
|
742 | 742 | e.on('focusin', function () { |
|
743 | that.command_mode(); | |
|
744 | 743 | that.disable(); |
|
745 | 744 | }); |
|
746 | 745 | e.on('focusout', function () { |
|
747 | that.command_mode(); | |
|
748 | 746 | that.enable(); |
|
749 | 747 | }); |
|
750 | 748 | // There are times (raw_input) where we remove the element from the DOM before |
|
751 | 749 | // focusout is called. In this case we bind to the remove event of jQueryUI, |
|
752 | 750 | // which gets triggered upon removal. |
|
753 | 751 | e.on('remove', function () { |
|
754 | that.command_mode(); | |
|
755 | 752 | that.enable(); |
|
756 | 753 | }); |
|
757 | 754 | } |
@@ -83,13 +83,20 b'' | |||
|
83 | 83 | console.error("View creation failed", model); |
|
84 | 84 | } |
|
85 | 85 | if (cell.widget_subarea) { |
|
86 | ||
|
87 | 86 | cell.widget_area.show(); |
|
87 | this._handle_display_view(view); | |
|
88 | 88 | cell.widget_subarea.append(view.$el); |
|
89 | 89 | } |
|
90 | 90 | } |
|
91 | 91 | }; |
|
92 | 92 | |
|
93 | WidgetManager.prototype._handle_display_view = function (view) { | |
|
94 | // Have the IPython keyboard manager disable its event | |
|
95 | // handling so the widget can capture keyboard input. | |
|
96 | // Note, this is only done on the outer most widget. | |
|
97 | IPython.keyboard_manager.register_events(view.$el); | |
|
98 | }; | |
|
99 | ||
|
93 | 100 | WidgetManager.prototype.create_view = function(model, options, view) { |
|
94 | 101 | // Creates a view for a particular model. |
|
95 | 102 | var view_name = model.get('_view_name'); |
@@ -109,24 +116,11 b'' | |||
|
109 | 116 | view.render(); |
|
110 | 117 | model.views.push(view); |
|
111 | 118 | model.on('destroy', view.remove, view); |
|
112 | ||
|
113 | this._handle_new_view(view); | |
|
114 | 119 | return view; |
|
115 | 120 | } |
|
116 | 121 | return null; |
|
117 | 122 | }; |
|
118 | 123 | |
|
119 | WidgetManager.prototype._handle_new_view = function (view) { | |
|
120 | // Called when a view has been created and rendered. | |
|
121 | ||
|
122 | // If the view has a well defined element, inform the keyboard | |
|
123 | // manager about the view's element, so as the element can | |
|
124 | // escape the dreaded command mode. | |
|
125 | if (view.$el) { | |
|
126 | IPython.keyboard_manager.register_events(view.$el); | |
|
127 | } | |
|
128 | }; | |
|
129 | ||
|
130 | 124 | WidgetManager.prototype.get_msg_cell = function (msg_id) { |
|
131 | 125 | var cell = null; |
|
132 | 126 | // First, check to see if the msg was triggered by cell execution. |
General Comments 0
You need to be logged in to leave comments.
Login now