built-in client: add nofocus client option to prevent the client window from taking focus unless a text input or a dropdown is clicked

This commit is contained in:
bordun 2021-06-23 22:32:24 +02:00
parent 13c7f80052
commit 7528f702aa
3 changed files with 12 additions and 0 deletions

View file

@ -5,6 +5,9 @@
- bug fixes
- range: value not properly updated with set()
- misc
- (built-in client only) add `nofocus` client option to prevent the client window from taking focus unless a text input or a dropdown is clicked.
## 1.9.10

View file

@ -13,6 +13,7 @@ Client options can be set either with the server's `--client-options` option, or
| consoleLength | number | 300 | sets the maximum number of log messages in the client's console |
| id | string | *random_id* | client's unique id (use with caution: two clients should never have the same id) |
| usePercents | 1 / 0 | 0 | sets the editor's "relative units" option |
| nofocus | 1 / 0 | 0 | (built-in client only) prevent the client window from taking focus unless a text input or a dropdown is clicked |
Example:

View file

@ -33,6 +33,10 @@ function mouseToFastClick(event) {
DOM.dispatchEvent(e.target, name, e)
if (ENV.nofocus && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
console.debug('ELECTRON.BLUR()')
}
}
function touchToFastClick(event) {
@ -59,6 +63,10 @@ function touchToFastClick(event) {
}, 600)
if (ENV.nofocus && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
console.debug('ELECTRON.BLUR()')
}
}
if (!iOS) document.addEventListener('pointerdown', mouseToFastClick, true)