-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for OpenURL to the web drivers (GopherJS and Wasm).
Resolve issue #2736.
- Loading branch information
Cedric BAIL
committed
Feb 25, 2022
1 parent
87f66cf
commit 6a31f2f
Showing
5 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//go:build !ci && js && !wasm | ||
// +build !ci,js,!wasm | ||
|
||
package app | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
|
||
"honnef.co/go/js/dom" | ||
) | ||
|
||
func (app *fyneApp) OpenURL(url *url.URL) error { | ||
window := dom.GetWindow().Open(url.String(), "_blank", "") | ||
if window == nil { | ||
return fmt.Errorf("Unable to open a new window/tab for URL: %v.", url) | ||
} | ||
window.Focus() | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//go:build !ci && wasm | ||
// +build !ci,wasm | ||
|
||
package app | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"syscall/js" | ||
) | ||
|
||
func (app *fyneApp) OpenURL(url *url.URL) error { | ||
window := js.Global().Call("open", url.String(), "_blank", "") | ||
if window.Equal(js.Null()) { | ||
return fmt.Errorf("Unable to open a new window/tab for URL: %v.", url) | ||
} | ||
window.Call("focus") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters