builtin client:change noFocus client option behavior: the defalt client window now doesn't take the focus at all, even when a text input is clicked.
This commit is contained in:
parent
dca6d2c889
commit
74f6c289e5
8 changed files with 48 additions and 4 deletions
|
|
@ -38,7 +38,7 @@ function mouseToFastClick(event) {
|
|||
|
||||
DOM.dispatchEvent(e.target, name, e)
|
||||
|
||||
if (ENV.nofocus && !editor.enabled && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
|
||||
if (!FOCUSABLE && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
|
||||
console.debug('ELECTRON.BLUR()')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ window.TOGGLE_ALT_TRAVERSING = !!ENV.altTraversing
|
|||
|
||||
window.VIRTUAL_KEYBOARD = !!ENV.virtualKeyboard
|
||||
|
||||
window.FOCUSABLE = !ENV.noFocus
|
||||
if (!FOCUSABLE) console.debug('ELECTRON.SETFOCUSABLE(0)')
|
||||
else console.debug('ELECTRON.SETFOCUSABLE(1)')
|
||||
|
||||
window.JSON.parseFlex = require('json5').parse
|
||||
|
||||
|
|
|
|||
|
|
@ -470,6 +470,14 @@ class ScriptVm extends Vm {
|
|||
|
||||
}
|
||||
|
||||
this.sandbox.contentWindow.setFocusable = (focusable)=>{
|
||||
|
||||
this.checkContext('setFocusable')
|
||||
FOCUSABLE = !!focusable
|
||||
console.debug('ELECTRON.SETFOCUSABLE('+(focusable ? 1 : 0)+')')
|
||||
|
||||
}
|
||||
|
||||
this.sandbox.contentWindow.toolbar = (...args)=>{
|
||||
|
||||
this.checkContext('toolbar')
|
||||
|
|
@ -525,7 +533,7 @@ class ScriptVm extends Vm {
|
|||
this.sandbox.contentWindow.Image = Image
|
||||
|
||||
for (var imports of ['set', 'get', 'getProp', 'getIndex', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage',
|
||||
'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'setFocus', 'unfocus', 'setScroll', 'getScroll', 'toolbar',
|
||||
'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'setFocus', 'unfocus' , 'setFocusable', 'setScroll', 'getScroll', 'toolbar',
|
||||
'openUrl', 'getVar', 'setVar', 'runAs', 'Image', 'updateCanvas']) {
|
||||
this.sanitize(this.sandbox.contentWindow[imports])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ module.exports = function(options={}) {
|
|||
})
|
||||
|
||||
|
||||
|
||||
// default geometry
|
||||
var currentScreen = screen.getDisplayNearestPoint(screen.getCursorScreenPoint()),
|
||||
screenSize = currentScreen.size,
|
||||
|
|
@ -102,6 +103,14 @@ module.exports = function(options={}) {
|
|||
|
||||
if (level === 0 && message === 'ELECTRON.BLUR()') window.blur()
|
||||
if (level === 0 && message === 'ELECTRON.FOCUS()') window.focus()
|
||||
if (level === 0 && message === 'ELECTRON.SETFOCUSABLE(1)') {
|
||||
window.setFocusable(true)
|
||||
window.focus()
|
||||
}
|
||||
if (level === 0 && message === 'ELECTRON.SETFOCUSABLE(0)') {
|
||||
window.setFocusable(false)
|
||||
window.blur()
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
|
@ -161,6 +170,9 @@ module.exports = function(options={}) {
|
|||
})
|
||||
}
|
||||
|
||||
window.setFocusable(!options.noFocus)
|
||||
|
||||
|
||||
return window
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,13 @@ function openClient() {
|
|||
var address = settings.appAddresses()[0]
|
||||
|
||||
var launch = ()=>{
|
||||
var win = require('./electron-window')({address:address, shortcuts:true, fullscreen: settings.read('fullscreen'), id: 'client'})
|
||||
var win = require('./electron-window')({
|
||||
address:address,
|
||||
shortcuts:true,
|
||||
fullscreen: settings.read('fullscreen'),
|
||||
noFocus: settings.read('client-options') && settings.read('client-options').some(x=>x.match(/nofocus=1/i)),
|
||||
id: 'client'
|
||||
})
|
||||
win.on('error', ()=>{
|
||||
console.log('ERR')
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue