Add keycap (and bound meta-o) to App

This commit is contained in:
Corey Johnson
2012-03-01 12:11:45 -08:00
parent 1e6a34db81
commit 15acd071ca
4 changed files with 18 additions and 11 deletions

View File

@@ -1,9 +1,11 @@
Native = require 'native'
GlobalKeymap = require 'global-keymap'
$ = require 'jquery'
_ = require 'underscore'
module.exports =
class App
keymap: null
native: null
windows: null
@@ -11,6 +13,18 @@ class App
@native = new Native(nativeMethods)
@windows = []
@setupKeymap()
setupKeymap: ->
@keymap = new GlobalKeymap()
@keymap.bindKeys "*",
'meta-o': 'open'
$(document).on 'open', =>
url = @native.openDialog()
@open(url) if url
$(document).on 'keydown', (e) => @keymap.handleKeyEvent(e)
open: (url) ->
@native.open url

View File

@@ -19,7 +19,7 @@ class GlobalKeymap
handleKeyEvent: (event) ->
event.keystroke = @keystrokeStringForEvent(event)
currentNode = $(event.target)
currentNode = $(event.target)
while currentNode.length
candidateBindingSets = @bindingSets.filter (set) -> currentNode.is(set.selector)
candidateBindingSets.sort (a, b) -> b.specificity - a.specificity

View File

@@ -44,10 +44,10 @@ windowAdditions =
$('head').append "<style path='#{fullPath}'>#{content}</style>"
showConsole: ->
# $atomController.webView.inspector.showConsole true
$native.showDevTools()
onerror: ->
@showConsole true
@showConsole()
for key, value of windowAdditions
console.warn "DOMWindow already has a key named `#{key}`" if window[key]
@@ -55,4 +55,3 @@ for key, value of windowAdditions
requireStylesheet 'reset.css'
requireStylesheet 'atom.css'

View File

@@ -16,13 +16,7 @@ class Native
# Returns null or a file path.
openPanel: ->
panel = OSX.NSOpenPanel.openPanel
panel.setCanChooseDirectories true
if panel.runModal isnt OSX.NSFileHandlingPanelOKButton
return null
filename = panel.filenames.lastObject
localStorage.lastOpenedPath = filename
filename.valueOf()
atom.native.openPanel()
# Returns null or a file path.
savePanel: ->