質問

I'm working on a desktop application that builds its interface in Chromium Embedded Framework. I need to disable text selection so the user can't drag over text (in a <p> or <a> tag) to select it. Selecting text in desktop applications is not normal, so this is important for our application as well. I am currently using CSS to disable text selection and JavaScript to override Ctrl + A, but I'm looking for a lower level way to directly disable it with the CEF application. Is this possible?

役に立ちましたか?

解決

Quick CSS solution like next, also preventing selection via keyboard shortcuts (Ctrl+A):

* {
    -webkit-user-select: none;
}

You just did not disable selection to all you elements (some of them still selectable).

I'm did not think that CEF3 currently has any low level solution to prevent text selection. And there is bad idea at all - you pages can contain content editable elements which want selection, so controlling it via CSS looks more flexible.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top