mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Listen for focus/blur on window, not document.
This commit is contained in:
@@ -67,7 +67,7 @@ describe "Window", ->
|
||||
|
||||
expect(atom.native.addMenuItem).not.toHaveBeenCalled()
|
||||
|
||||
$(document).focus()
|
||||
$(window).focus()
|
||||
|
||||
expect(atom.native.addMenuItem).toHaveBeenCalled()
|
||||
expect(addedPaths).toContain('Submenu 1 > Item 1')
|
||||
@@ -76,14 +76,14 @@ describe "Window", ->
|
||||
|
||||
spyOn(atom.native, 'resetMainMenu')
|
||||
|
||||
$(document).blur()
|
||||
$(window).blur()
|
||||
|
||||
expect(atom.native.resetMainMenu).toHaveBeenCalled()
|
||||
|
||||
it "causes the given action to be invoked when the menu item is selected", ->
|
||||
handler = jasmine.createSpy('menuItemHandler')
|
||||
window.bindMenuItem 'Submenu > Item', handler
|
||||
$(document).focus()
|
||||
$(window).focus()
|
||||
|
||||
OSX.NSApp.mainMenu.itemWithTitle('Submenu').submenu.performActionForItemAtIndex(0)
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ windowAdditions =
|
||||
@registerEventHandlers()
|
||||
@bindKeys()
|
||||
@bindMenuItems()
|
||||
$(document).focus()
|
||||
$(window).focus()
|
||||
|
||||
shutdown: ->
|
||||
@layout.remove()
|
||||
@editor.shutdown()
|
||||
$(document).unbind('focus')
|
||||
$(document).unbind('focus')
|
||||
$(window).unbind('focus')
|
||||
$(window).unbind('blur')
|
||||
$(window).unbind('keydown')
|
||||
|
||||
bindKeys: ->
|
||||
@@ -62,8 +62,8 @@ windowAdditions =
|
||||
for pattern, action of @keyBindings
|
||||
action() if @keyEventMatchesPattern(event, pattern)
|
||||
|
||||
$(document).focus => @registerMenuItems()
|
||||
$(document).blur -> atom.native.resetMainMenu()
|
||||
$(window).focus => @registerMenuItems()
|
||||
$(window).blur -> atom.native.resetMainMenu()
|
||||
|
||||
registerMenuItems: ->
|
||||
for path of @menuItemActions
|
||||
|
||||
Reference in New Issue
Block a user