From b9f844ab187dbd9b02f2b6c26bbda4166c78c746 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 26 Dec 2011 23:32:54 -0600 Subject: [PATCH] Listen for focus/blur on window, not document. --- spec/atom/window-spec.coffee | 6 +++--- src/atom/window.coffee | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/atom/window-spec.coffee b/spec/atom/window-spec.coffee index a1eb4541d..cd559c589 100644 --- a/spec/atom/window-spec.coffee +++ b/spec/atom/window-spec.coffee @@ -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) diff --git a/src/atom/window.coffee b/src/atom/window.coffee index 1fa6d10b3..9abbff215 100644 --- a/src/atom/window.coffee +++ b/src/atom/window.coffee @@ -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