This commit is contained in:
Andrea Bogazzi 2018-03-01 01:37:36 +01:00 committed by GitHub
parent d0a4ecba21
commit 8235c1aea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,12 +15,17 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
this.on('mousedown', this.onMouseDown.bind(this));
},
/**
* Default event handler to simulate triple click
* @private
*/
onMouseDown: function(options) {
if (!this.canvas) {
return;
}
this.__newClickTime = +new Date();
var newPointer = this.canvas.getPointer(options.e);
if (this.isTripleClick(newPointer, options.e)) {
if (this.isTripleClick(newPointer)) {
this.fire('tripleclick', options);
this._stopEvent(options.e);
}
@ -104,6 +109,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
},
/**
* detect if object moved
* @private
*/
_isObjectMoved: function(e) {
@ -117,23 +123,29 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
* Initializes "mouseup" event handler
*/
initMouseupHandler: function() {
this.on('mouseup', function(options) {
this.__isMousedown = false;
if (!this.editable || this._isObjectMoved(options.e) || (options.e.button && options.e.button !== 1)) {
return;
}
this.on('mouseup', this.mouseUpHandler);
},
if (this.__lastSelected && !this.__corner) {
this.enterEditing(options.e);
if (this.selectionStart === this.selectionEnd) {
this.initDelayedCursor(true);
}
else {
this.renderCursorOrSelection();
}
/**
* standard hander for mouse up, overridable
* @private
*/
mouseUpHandler: function(options) {
this.__isMousedown = false;
if (!this.editable || this._isObjectMoved(options.e) || (options.e.button && options.e.button !== 1)) {
return;
}
if (this.__lastSelected && !this.__corner) {
this.enterEditing(options.e);
if (this.selectionStart === this.selectionEnd) {
this.initDelayedCursor(true);
}
this.selected = true;
});
else {
this.renderCursorOrSelection();
}
}
this.selected = true;
},
/**