1. Miscellaneous
  2. Implementing Native Text Selection Behavior

Miscellaneous

Implementing Native Text Selection Behavior

In web applications, generally all text is selectable. In desktop applications, text selection is typically limited to elements that you may want to copy and paste (e.g. input fields).

If you wish to replicate native text selection in ToDesktop Builder apps, you can use the user-select CSS properties. These properties will disable text selection for all elements except those explicitly allowed, such as input fields. Read more about the user-select property on MDN.

        html.todesktop {
  user-select: none;
  -webkit-user-select: none;
}

      
INFO

The html.todesktop class pre-selector will ensure that the css is only applied when running as a desktop app. For more information on custom CSS in ToDesktop apps, see our detailed guide.

If you want to re-activate text selection for certain elements, you can do the following:

        html.todesktop .custom-element {
  user-select: auto;
  -webkit-user-select: auto;
}