Bug fix: Check window.top's focus in case that game is in <iframe>

This commit is contained in:
Hajime Hoshi 2015-01-08 02:24:05 +09:00
parent a1214ff735
commit d933c54e20

View File

@ -31,10 +31,11 @@ var windowIsFocused = true
func init() { func init() {
// TODO: Check IE // TODO: Check IE
window := js.Global.Get("window") window := js.Global.Get("window")
window.Set("onfocus", func() { // Get the top window in case that this window is in an iframe.
window.Get("top").Call("addEventListener", "focus", func() {
windowIsFocused = true windowIsFocused = true
}) })
window.Set("onblur", func() { window.Get("top").Call("addEventListener", "blur", func() {
windowIsFocused = false windowIsFocused = false
}) })
} }