Fixed esc shortcut when editor is disabled.
This commit is contained in:
parent
e5b87e5158
commit
cfe1b020c3
2 changed files with 16 additions and 6 deletions
app
|
@ -66,7 +66,7 @@
|
||||||
&.disabled
|
&.disabled
|
||||||
@include opacity(0.8)
|
@include opacity(0.8)
|
||||||
.ace_cursor, .executing, .ace_active-line, .ace_gutter-active-line
|
.ace_cursor, .executing, .ace_active-line, .ace_gutter-active-line
|
||||||
@include opacity(0.2)
|
@include opacity(0.1)
|
||||||
|
|
||||||
.ace_gutter
|
.ace_gutter
|
||||||
background-color: transparent
|
background-color: transparent
|
||||||
|
|
|
@ -131,13 +131,12 @@ module.exports = class SpellView extends CocoView
|
||||||
addCommand
|
addCommand
|
||||||
name: 'toggle-playing'
|
name: 'toggle-playing'
|
||||||
bindKey: {win: 'Ctrl-P', mac: 'Command-P|Ctrl-P'}
|
bindKey: {win: 'Ctrl-P', mac: 'Command-P|Ctrl-P'}
|
||||||
|
readOnly: true
|
||||||
exec: -> Backbone.Mediator.publish 'level:toggle-playing', {}
|
exec: -> Backbone.Mediator.publish 'level:toggle-playing', {}
|
||||||
addCommand
|
addCommand
|
||||||
name: 'end-current-script'
|
name: 'end-current-script'
|
||||||
bindKey: {win: 'Shift-Space', mac: 'Shift-Space'}
|
bindKey: {win: 'Shift-Space', mac: 'Shift-Space'}
|
||||||
# passEvent: true # https://github.com/ajaxorg/ace/blob/master/lib/ace/keyboard/keybinding.js#L114
|
readOnly: true
|
||||||
# No easy way to selectively cancel shift+space, since we don't get access to the event.
|
|
||||||
# Maybe we could temporarily set ourselves to read-only if we somehow know that a script is active?
|
|
||||||
exec: =>
|
exec: =>
|
||||||
if @scriptRunning
|
if @scriptRunning
|
||||||
Backbone.Mediator.publish 'level:shift-space-pressed', {}
|
Backbone.Mediator.publish 'level:shift-space-pressed', {}
|
||||||
|
@ -147,34 +146,44 @@ module.exports = class SpellView extends CocoView
|
||||||
addCommand
|
addCommand
|
||||||
name: 'end-all-scripts'
|
name: 'end-all-scripts'
|
||||||
bindKey: {win: 'Escape', mac: 'Escape'}
|
bindKey: {win: 'Escape', mac: 'Escape'}
|
||||||
exec: -> Backbone.Mediator.publish 'level:escape-pressed', {}
|
readOnly: true
|
||||||
|
exec: ->
|
||||||
|
console.log 'esc pressed'
|
||||||
|
Backbone.Mediator.publish 'level:escape-pressed', {}
|
||||||
addCommand
|
addCommand
|
||||||
name: 'toggle-grid'
|
name: 'toggle-grid'
|
||||||
bindKey: {win: 'Ctrl-G', mac: 'Command-G|Ctrl-G'}
|
bindKey: {win: 'Ctrl-G', mac: 'Command-G|Ctrl-G'}
|
||||||
|
readOnly: true
|
||||||
exec: -> Backbone.Mediator.publish 'level:toggle-grid', {}
|
exec: -> Backbone.Mediator.publish 'level:toggle-grid', {}
|
||||||
addCommand
|
addCommand
|
||||||
name: 'toggle-debug'
|
name: 'toggle-debug'
|
||||||
bindKey: {win: 'Ctrl-\\', mac: 'Command-\\|Ctrl-\\'}
|
bindKey: {win: 'Ctrl-\\', mac: 'Command-\\|Ctrl-\\'}
|
||||||
|
readOnly: true
|
||||||
exec: -> Backbone.Mediator.publish 'level:toggle-debug', {}
|
exec: -> Backbone.Mediator.publish 'level:toggle-debug', {}
|
||||||
addCommand
|
addCommand
|
||||||
name: 'toggle-pathfinding'
|
name: 'toggle-pathfinding'
|
||||||
bindKey: {win: 'Ctrl-O', mac: 'Command-O|Ctrl-O'}
|
bindKey: {win: 'Ctrl-O', mac: 'Command-O|Ctrl-O'}
|
||||||
|
readOnly: true
|
||||||
exec: -> Backbone.Mediator.publish 'level:toggle-pathfinding', {}
|
exec: -> Backbone.Mediator.publish 'level:toggle-pathfinding', {}
|
||||||
addCommand
|
addCommand
|
||||||
name: 'level-scrub-forward'
|
name: 'level-scrub-forward'
|
||||||
bindKey: {win: 'Ctrl-]', mac: 'Command-]|Ctrl-]'}
|
bindKey: {win: 'Ctrl-]', mac: 'Command-]|Ctrl-]'}
|
||||||
|
readOnly: true
|
||||||
exec: -> Backbone.Mediator.publish 'level:scrub-forward', {}
|
exec: -> Backbone.Mediator.publish 'level:scrub-forward', {}
|
||||||
addCommand
|
addCommand
|
||||||
name: 'level-scrub-back'
|
name: 'level-scrub-back'
|
||||||
bindKey: {win: 'Ctrl-[', mac: 'Command-[|Ctrl-]'}
|
bindKey: {win: 'Ctrl-[', mac: 'Command-[|Ctrl-]'}
|
||||||
|
readOnly: true
|
||||||
exec: -> Backbone.Mediator.publish 'level:scrub-back', {}
|
exec: -> Backbone.Mediator.publish 'level:scrub-back', {}
|
||||||
addCommand
|
addCommand
|
||||||
name: 'spell-step-forward'
|
name: 'spell-step-forward'
|
||||||
bindKey: {win: 'Ctrl-Alt-]', mac: 'Command-Alt-]|Ctrl-Alt-]'}
|
bindKey: {win: 'Ctrl-Alt-]', mac: 'Command-Alt-]|Ctrl-Alt-]'}
|
||||||
|
readOnly: true
|
||||||
exec: -> Backbone.Mediator.publish 'tome:spell-step-forward', {}
|
exec: -> Backbone.Mediator.publish 'tome:spell-step-forward', {}
|
||||||
addCommand
|
addCommand
|
||||||
name: 'spell-step-backward'
|
name: 'spell-step-backward'
|
||||||
bindKey: {win: 'Ctrl-Alt-[', mac: 'Command-Alt-[|Ctrl-Alt-]'}
|
bindKey: {win: 'Ctrl-Alt-[', mac: 'Command-Alt-[|Ctrl-Alt-]'}
|
||||||
|
readOnly: true
|
||||||
exec: -> Backbone.Mediator.publish 'tome:spell-step-backward', {}
|
exec: -> Backbone.Mediator.publish 'tome:spell-step-backward', {}
|
||||||
addCommand
|
addCommand
|
||||||
name: 'spell-beautify'
|
name: 'spell-beautify'
|
||||||
|
@ -815,10 +824,11 @@ module.exports = class SpellView extends CocoView
|
||||||
return if enabled is @controlsEnabled
|
return if enabled is @controlsEnabled
|
||||||
@controlsEnabled = enabled and @writable
|
@controlsEnabled = enabled and @writable
|
||||||
disabled = not enabled
|
disabled = not enabled
|
||||||
$('body').focus() if disabled and $(document.activeElement).is('.ace_text-input')
|
wasFocused = @ace.isFocused()
|
||||||
@ace.setReadOnly disabled
|
@ace.setReadOnly disabled
|
||||||
@ace[if disabled then 'setStyle' else 'unsetStyle'] 'disabled'
|
@ace[if disabled then 'setStyle' else 'unsetStyle'] 'disabled'
|
||||||
@toggleBackground()
|
@toggleBackground()
|
||||||
|
$('body').focus() if disabled and wasFocused
|
||||||
|
|
||||||
toggleBackground: =>
|
toggleBackground: =>
|
||||||
# TODO: make the background an actual background and do the CSS trick
|
# TODO: make the background an actual background and do the CSS trick
|
||||||
|
|
Reference in a new issue