Open a hyperlink in the default browser.
hyperlink.NewShare:- Creates a instance of Share struct, given the config.
hyperlink.Configure:- Updates the current Share with the given config.
hyperlink.Open:- Opens the link in the default browser.
- By default, only supports
httpandhttpsschemes.
If you want to use it without plugin, read the Freestanding instructions. We provide some helper functions, such as NewConfigFromViewEvent and such.
To open one link, you can use the Open operation.
That will open the link in the default browser. You can use OpenURL to open a *url.URL:
gioplugins.Execute(gtx, giohyperlink.OpenOp{URI: &url.URL{
Scheme: "https",
Host: "github.com",
}})Operations must be added with gioplugins.Execute method. The operation will be executed at the end of the frame.
giohyperlink.OpenCmd:- Opens the link in the default browser. Currently, only supports
httpandhttpsschemes.
- Opens the link in the default browser. Currently, only supports
Events are response sent using the Tag and should be handled with gioplugins.Event().
giohyperlink.ErrorEvent:- Sent to
Tagwhen it's not possible to open the hyperlink.
- Sent to
| Features | Windows | Android | MacOS | iOS | WebAssembly | FreeBSD | Linux |
|---|---|---|---|---|---|---|---|
| HTTP | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| HTTPS | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
By default, only HTTP and HTTPS links are allowed, but you can change that by changing InsecureIgnoreScheme to true,
you should validate the URL and scheme on your own.