Skip to content

Commit

Permalink
Block backspace from leaving the page
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmire committed Apr 1, 2012
1 parent 170e5a1 commit 03c7406
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
6 changes: 6 additions & 0 deletions app/javascripts/editor/core.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ define 'editor.core', ->
@_changeLayerTo(0) # currentTool is already set
@viewport.loadMap()

# Block backspace from leaving the page
$(window)
.bind "keydown.editor.core", (evt) =>
if @keyboard.isKeyPressed(evt, 'backspace')
evt.preventDefault()

getLayers: -> LAYER_NAMES

getCurrentLayer: -> @currentLayer
Expand Down
9 changes: 3 additions & 6 deletions app/javascripts/editor/viewport.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,8 @@ define 'editor.viewport', ->
.removeAttr('data-is-selected')

$(window)
# this cannot be on keyup b/c backspace will go back to the prev page
# immediately on keydown so we have to catch that
.bind "keydown.#{evtns}", (evt) =>
.bind "keyup.#{evtns}", (evt) =>
if @keyboard.isKeyPressed(evt, 'backspace', 'delete')
evt.preventDefault()
$selectedObjects = @$map.find('.editor-map-object.editor-selected')
if $selectedObjects.length
$selectedObjects.each (elem) =>
Expand Down Expand Up @@ -332,9 +329,9 @@ define 'editor.viewport', ->
setTimeout selectionEvents.add, 0

$(window)
.bind "keydown.#{evtns}", (evt) =>
.bind "keyup.#{evtns}", (evt) =>
Bounds = require('game.Bounds')
# if evt.metaKey and @keyboard.isKeyPressed(evt, 'backspace')
# TODO: Make this Cmd-Backspace
if @keyboard.isKeyPressed(evt, 'F')
# fill all of the selections
$.v.each activeSelections, (sel) =>
Expand Down
7 changes: 6 additions & 1 deletion public/javascripts/app/editor/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions public/javascripts/app/editor/viewport.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 03c7406

Please sign in to comment.