How to disable in ace editor the selection

ace-editor, javascript

Solution

You can effectively prevent selection by setting the editor to read only then overriding the selection style in the theme:

.noselection .ace_marker-layer .ace_selection {
   background: transparent;
}

.noselection .ace_cursor {
   color: transparent;
}

Then just add the `noselection` class to your ace container div.

This won't actually prevent the user selecting anything, but there will be no visual indication that its happening; which for all intents and purposes is pretty much the same thing.

Lots more detail here:

https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode

There is also this approach:

https://github.com/ajaxorg/ace/issues/266

Problem

Does anyone know how can I disable the selection of ace.editor? No word selection by mouse and finger. I tried to use `editor.selection(false);` but that does not work.

Original source