Move GlobalKeymap instance to App. Clear bindings between examples.

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-01-11 11:42:22 -08:00
parent 766f301bc1
commit 1aa99c379f
5 changed files with 19 additions and 10 deletions

View File

@@ -1,14 +1,19 @@
Native = require 'native'
GlobalKeymap = require 'global-keymap'
$ = require 'jquery'
module.exports =
class App
globalKeymap: null
native: null
constructor: ->
@native = new Native
@globalKeymap = new GlobalKeymap
$(document).on 'keydown', (e) => console.log e; @globalKeymap.handleKeyEvent(e)
bindKeys: (selector, bindings) ->
window.rootView.bindKeys(selector, bindings)
@globalKeymap.bindKeys(selector, bindings)
open: (url) ->
OSX.NSApp.open url

View File

@@ -23,3 +23,6 @@ class GlobalKeymap
return true
currentNode = currentNode.parent()
false
reset: ->
@BindingSets = []

View File

@@ -22,22 +22,16 @@ class RootView extends Template
globalKeymap: null
initialize: ({url}) ->
@createGlobalKeymap()
@editor.keyEventHandler = atom.globalKeymap
@createProject(url)
@bindKeys '*'
atom.bindKeys '*'
'meta-s': 'save'
'meta-w': 'close'
'meta-t': 'toggle-file-finder'
@on 'toggle-file-finder', => @toggleFileFinder()
createGlobalKeymap: ->
@globalKeymap = new GlobalKeymap
@on 'keydown', (e) => @globalKeymap.handleKeyEvent(e)
@editor.keyEventHandler = @globalKeymap
createProject: (url) ->
if url
@project = new Project(fs.directory(url))