Permalink
Browse files

Trigger the blur event only if there is no selection

  • Loading branch information...
1 parent 2b327bf commit 74d8cc8684afb974a68300beb429073ad51690be @benbro benbro committed Jan 9, 2013
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/codemirror-adapter.js
View
@@ -12,7 +12,7 @@ ot.CodeMirrorAdapter = (function () {
var self = this;
cm.on('change', function (_, change) { self.onChange(change); });
cm.on('cursorActivity', function () { self.trigger('cursorActivity'); });
- cm.on('blur', function () { self.trigger('blur'); });
+ cm.on('blur', function () { self.onBlur(); });
}
// The oldValue is needed to find
@@ -143,6 +143,12 @@ ot.CodeMirrorAdapter = (function () {
this.oldValue = this.cm.getValue();
};
+ CodeMirrorAdapter.prototype.onBlur = function () {
+ if(!cm.getSelection()) {
+ this.trigger('blur');
+ }
+ }
+
CodeMirrorAdapter.prototype.getValue = function () {
return this.oldValue;
};
@@ -255,4 +261,4 @@ ot.CodeMirrorAdapter = (function () {
return CodeMirrorAdapter;
-}());
+}());

0 comments on commit 74d8cc8

Please sign in to comment.