As I develop an application that alters the default selection behavior to allow the copying and pasting of elements, a challenge has arisen. Disabling the ability to select also eliminates copy events.
I initially attempted to use the following:
onselectstart="return false;"
and
.no-select {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
While these methods successfully disabled selecting, they also hindered copying.
Subsequently, I experimented with applying the .no-select
attribute solely to text-containing sections, but this approach proved challenging to maintain and inconsistent in functionality – leading to unpredictable blocking of copy events.
My inquiry is this - How can I effectively disable selection while enabling proper copy/paste mechanisms?
Edit:
- I am not looking to copy text, but instead my own JSON structures. Copying is managed within the
onCopy
handler. - I must be able to intercept standard Chrome copy events triggered by the Chrome menu or system shortcuts.