##// END OF EJS Templates
Starting work on select/focus logic.
Brian E. Granger -
Show More
@@ -39,6 +39,7 var IPython = (function (IPython) {
39 39 this.placeholder = options.placeholder || '';
40 40 this.read_only = options.cm_config.readOnly;
41 41 this.selected = false;
42 this.focused = false;
42 43 this.metadata = {};
43 44 // load this from metadata later ?
44 45 this.user_highlight = 'auto';
@@ -136,7 +137,7 var IPython = (function (IPython) {
136 137 };
137 138
138 139 /**
139 * should be triggerd when cell is selected
140 * handle cell level logic when a cell is selected
140 141 * @method select
141 142 */
142 143 Cell.prototype.select = function () {
@@ -144,9 +145,8 var IPython = (function (IPython) {
144 145 this.selected = true;
145 146 };
146 147
147
148 148 /**
149 * should be triggerd when cell is unselected
149 * handle cell level logic when a cell is unselected
150 150 * @method unselect
151 151 */
152 152 Cell.prototype.unselect = function () {
@@ -155,6 +155,24 var IPython = (function (IPython) {
155 155 };
156 156
157 157 /**
158 * handle cell level logic when a cell is focused
159 * @method focus
160 */
161 Cell.prototype.focus = function () {
162 this.element.addClass('focused');
163 this.focused = true;
164 };
165
166 /**
167 * handle cell level logic when a cell is unfocused
168 * @method unfocus
169 */
170 Cell.prototype.unfocus = function () {
171 this.element.removeClass('focused');
172 this.focused = false;
173 };
174
175 /**
158 176 * should be overritten by subclass
159 177 * @method get_text
160 178 */
@@ -306,13 +306,18 var IPython = (function (IPython) {
306 306 CodeCell.prototype.select = function () {
307 307 IPython.Cell.prototype.select.apply(this);
308 308 this.code_mirror.refresh();
309 this.code_mirror.focus();
310 309 this.auto_highlight();
311 // We used to need an additional refresh() after the focus, but
312 // it appears that this has been fixed in CM. This bug would show
313 // up on FF when a newly loaded markdown cell was edited.
314 310 };
315 311
312 CodeCell.prototype.focus = function () {
313 IPython.Cell.prototype.focus.apply(this);
314 this.code_mirror.focus();
315 };
316
317 CodeCell.prototype.unfocus = function () {
318 IPython.Cell.prototype.focus.apply(this);
319 this.code_mirror.blur();
320 };
316 321
317 322 CodeCell.prototype.select_all = function () {
318 323 var start = {line: 0, ch: 0};
General Comments 0
You need to be logged in to leave comments. Login now