script: bypass keyboard shortcuts already used by the editor if it is enabled
This commit is contained in:
parent
b39477dd12
commit
38c2750b14
3 changed files with 9 additions and 1 deletions
|
|
@ -8,6 +8,8 @@
|
|||
- editor
|
||||
- change keyboard shortcuts for moving widgets (now `mod + arrows`) and navigating in widgets (now `arrows`) to feel more natural with the project tree view.
|
||||
|
||||
- widgets
|
||||
- script: bypass keyboard shortcuts already used by the editor if it is enabled
|
||||
|
||||
## 1.9.6
|
||||
|
||||
|
|
|
|||
|
|
@ -209,6 +209,7 @@ class Editor {
|
|||
|
||||
for (let c of combos) {
|
||||
keyboardJS.bind(c, (e)=>{
|
||||
e.catchedByEditor = true
|
||||
this.handleKeyboard(c, e)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ class Script extends Widget {
|
|||
|
||||
_separator: 'event: keyboard',
|
||||
|
||||
keyBinding: {type: 'string|array', value: '', help: 'Key combo `string` or `array` of strings (see <a href="https://github.com/RobertWHurst/KeyboardJS">KeyboardJS</a> documentation)'},
|
||||
keyBinding: {type: 'string|array', value: '', help: [
|
||||
'Key combo `string` or `array` of strings (see <a href="https://github.com/RobertWHurst/KeyboardJS">KeyboardJS</a> documentation).',
|
||||
'If the editor is enabled, some keys / combos will not work.'
|
||||
]},
|
||||
keyRepeat: {type: 'boolean', value: true, help: 'Set to `false` to prevent keydown repeats when holding the key combo pressed'},
|
||||
keyType: {type: 'string', value: 'keydown', choices: ['keydown', 'keyup', 'both'], help: 'Determines which key event trigger the script\'s execution'},
|
||||
|
||||
|
|
@ -145,6 +148,8 @@ class Script extends Widget {
|
|||
|
||||
keyboardCallback(e) {
|
||||
|
||||
if (e.catchedByEditor) return
|
||||
|
||||
if (e.target && (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.tagName === 'SELECT')) return
|
||||
|
||||
if (this.getProp('keyType') !== 'both' && e.type !== this.getProp('keyType')) return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue