Created
May 21, 2015 08:37
-
-
Save coclav/10455502674fb062b2c5 to your computer and use it in GitHub Desktop.
selectionAllowed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// function that will tell the browser if you can "select" the field or not ... returns false most of the time | |
skShell.textEditing = mxUtils.bind(this, function (evt) { // this binds this to the current element... not sure you actually need that | |
evt = evt || window.event; | |
// tells if the evt target has the class "selectionAllowed" | |
if (this.isSelectionAllowed(evt)) { | |
return true; // normal behaviour (selection, context menu...) | |
} | |
// other cases to deal with... (dialog) | |
return skShell.graph.isEditing() || this.dialog != null || skShell.menu.dialog != null; | |
}); | |
// each time the user selects or click, we check if something needs to happen or not | |
document.onselectstart = skShell.textEditing; | |
document.onmousedown = skShell.textEditing; | |
// And uses built-in context menu while editing | |
if (mxClient.IS_IE && document.documentMode != 9) { | |
mxEvent.addListener(this.container, 'contextmenu', skShell.textEditing); | |
} | |
else { | |
document.oncontextmenu = skShell.textEditing; | |
} | |
// selection allowed | |
this.isSelectionAllowed = function (evt) { | |
return !!(evt && $(evt.toElement || evt.relatedTarget).hasClass("selectionAllowed")); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment