Focus WebContents when we first load url in BrowserWindow
This commit is contained in:
parent
9bb87af66b
commit
29c574cf0f
2 changed files with 10 additions and 0 deletions
|
@ -30,6 +30,15 @@ BrowserWindow::_init = ->
|
||||||
@webContents.on 'crashed', =>
|
@webContents.on 'crashed', =>
|
||||||
@emit 'crashed'
|
@emit 'crashed'
|
||||||
|
|
||||||
|
# Sometimes the webContents doesn't get focus when window is shown, so we have
|
||||||
|
# to force focusing on webContents in this case. The safest way is to focus it
|
||||||
|
# when we first start to load URL, if we do it earlier it won't have effect,
|
||||||
|
# if we do it later we might move focus in the page.
|
||||||
|
# Though this hack is only needed on OS X when the app is launched from
|
||||||
|
# Finder, we still do it on all platforms in case of other bugs we don't know.
|
||||||
|
@webContents.once 'load-url', ->
|
||||||
|
@focus()
|
||||||
|
|
||||||
# Redirect focus/blur event to app instance too.
|
# Redirect focus/blur event to app instance too.
|
||||||
@on 'blur', (event) =>
|
@on 'blur', (event) =>
|
||||||
app.emit 'browser-window-blur', event, this
|
app.emit 'browser-window-blur', event, this
|
||||||
|
|
|
@ -40,6 +40,7 @@ class NavigationController
|
||||||
loadUrl: (url, options={}) ->
|
loadUrl: (url, options={}) ->
|
||||||
@pendingIndex = -1
|
@pendingIndex = -1
|
||||||
@webContents._loadUrl url, options
|
@webContents._loadUrl url, options
|
||||||
|
@webContents.emit 'load-url', url, options
|
||||||
|
|
||||||
getUrl: ->
|
getUrl: ->
|
||||||
if @currentIndex is -1
|
if @currentIndex is -1
|
||||||
|
|
Loading…
Reference in a new issue