Skip to content

Commit

Permalink
bring selectAll on keydown again (#2951)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur committed May 8, 2016
1 parent fcfc9f4 commit 3ab5cdb
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/mixins/itext_key_behavior.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,18 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
/**
* @private
*/
_ctrlKeysMap: {
65: 'selectAll',
_ctrlKeysMapUp: {
67: 'copy',
88: 'cut'
},

/**
* @private
*/
_ctrlKeysMapDown: {
65: 'selectAll'
},

onClick: function() {
// No need to trigger click event here, focus is enough to have the keyboard appear on Android
this.hiddenTextarea && this.hiddenTextarea.focus();
Expand All @@ -84,6 +90,9 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
if (e.keyCode in this._keysMap) {
this[this._keysMap[e.keyCode]](e);
}
else if ((e.keyCode in this._ctrlKeysMapDown) && (e.ctrlKey || e.metaKey)) {
this[this._ctrlKeysMapDown[e.keyCode]](e);
}
else {
return;
}
Expand All @@ -94,6 +103,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot

/**
* Handles keyup event
* We handle KeyUp because ie11 and edge have difficulties copy/pasting
* if a copy/cut event fired, keyup is dismissed
* @param {Event} e Event object
*/
Expand All @@ -102,8 +112,8 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
this._copyDone = false;
return;
}
if ((e.keyCode in this._ctrlKeysMap) && (e.ctrlKey || e.metaKey)) {
this[this._ctrlKeysMap[e.keyCode]](e);
if ((e.keyCode in this._ctrlKeysMapUp) && (e.ctrlKey || e.metaKey)) {
this[this._ctrlKeysMapUp[e.keyCode]](e);
}
else {
return;
Expand Down

0 comments on commit 3ab5cdb

Please sign in to comment.