mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Use ApplicationDelegate in WindowEventHandler
Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
This commit is contained in:
@@ -125,3 +125,9 @@ class ApplicationDelegate
|
||||
ipc.on('context-command', callback)
|
||||
new Disposable ->
|
||||
ipc.removeEventListener('context-command', callback)
|
||||
|
||||
didCancelWindowUnload: ->
|
||||
ipc.send('did-cancel-window-unload')
|
||||
|
||||
openExternal: (url) ->
|
||||
shell.openExternal(url)
|
||||
|
||||
@@ -264,7 +264,7 @@ class AtomApplication
|
||||
@promptForPath "folder", (selectedPaths) ->
|
||||
event.sender.send(responseChannel, selectedPaths)
|
||||
|
||||
ipc.on 'cancel-window-close', =>
|
||||
ipc.on 'did-cancel-window-unload', =>
|
||||
@quitting = false
|
||||
|
||||
clipboard = require '../safe-clipboard'
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
path = require 'path'
|
||||
{Disposable, CompositeDisposable} = require 'event-kit'
|
||||
ipc = require 'ipc'
|
||||
shell = require 'shell'
|
||||
fs = require 'fs-plus'
|
||||
listen = require './delegated-listener'
|
||||
|
||||
# Handles low-level events related to the window.
|
||||
module.exports =
|
||||
class WindowEventHandler
|
||||
constructor: ({@atomEnvironment}) ->
|
||||
constructor: ({@atomEnvironment, @applicationDelegate}) ->
|
||||
@reloadRequested = false
|
||||
@subscriptions = new CompositeDisposable
|
||||
|
||||
@@ -46,7 +44,7 @@ class WindowEventHandler
|
||||
bindCommandToAction = (command, action) =>
|
||||
@addEventListener document, command, (event) =>
|
||||
if event.target.webkitMatchesSelector('.native-key-bindings')
|
||||
@atomEnvironment.getCurrentWindow().webContents[action]()
|
||||
@applicationDelegate.getCurrentWindow().webContents[action]()
|
||||
|
||||
bindCommandToAction('core:copy', 'copy')
|
||||
bindCommandToAction('core:paste', 'paste')
|
||||
@@ -147,7 +145,7 @@ class WindowEventHandler
|
||||
if confirmed
|
||||
@atomEnvironment.unloadEditorWindow()
|
||||
else
|
||||
ipc.send('cancel-window-close')
|
||||
@applicationDelegate.didCancelWindowUnload()
|
||||
|
||||
confirmed
|
||||
|
||||
@@ -176,9 +174,9 @@ class WindowEventHandler
|
||||
|
||||
handleLinkClick: (event) ->
|
||||
event.preventDefault()
|
||||
location = event.currentTarget?.getAttribute('href')
|
||||
if location and location[0] isnt '#' and /^https?:\/\//.test(location)
|
||||
shell.openExternal(location)
|
||||
uri = event.currentTarget?.getAttribute('href')
|
||||
if uri and uri[0] isnt '#' and /^https?:\/\//.test(uri)
|
||||
@applicationDelegate.openExternal(uri)
|
||||
|
||||
handleFormSubmit: (event) ->
|
||||
# Prevent form submits from changing the current window's URL
|
||||
|
||||
Reference in New Issue
Block a user