Documentation
¶
Index ¶
Constants ¶
View Source
const ( // Width and height are default size HintNone = C.WEBVIEW_HINT_NONE // Window size can not be changed by a user HintFixed = C.WEBVIEW_HINT_FIXED // Width and height are minimum bounds HintMin = C.WEBVIEW_HINT_MIN // Width and height are maximum bounds HintMax = C.WEBVIEW_HINT_MAX //--------------------------------------------------------- MacOS Linux Windows WindowClose = C.WEBVIEW_WINDOW_CLOSE // 0 + + + WindowFocus = C.WEBVIEW_WINDOW_FOCUS // 1 + + + WindowBlur = C.WEBVIEW_WINDOW_BLUR // 2 + + + WindowMove = C.WEBVIEW_WINDOW_MOVE // 3 + + + WindowResize = C.WEBVIEW_WINDOW_RESIZE // 4 + + + WindowFullScreen = C.WEBVIEW_WINDOW_FULLSCREEN // 5 + + + WindowExitFullScreen = C.WEBVIEW_WINDOW_EXITFULLSCREEN // 6 + + + WindowMaximize = C.WEBVIEW_WINDOW_MAXIMIZE // 7 - + + WindowUnmaximize = C.WEBVIEW_WINDOW_UNMAXIMIZE // 8 - + - WindowMinimize = C.WEBVIEW_WINDOW_MINIMIZE // 9 + + + WindowUnminimize = C.WEBVIEW_WINDOW_UNMINIMIZE // 10 + + - )
Variables ¶
View Source
var EF embed.FS
Functions ¶
This section is empty.
Types ¶
type WebView ¶
type WebView interface {
// Run runs the main loop until it's terminated. After this function exits -
// you must destroy the webview.
Run()
// Terminate stops the main loop. It is safe to call this function from
// a background thread.
Terminate()
// Dispatch posts a function to be executed on the main thread. You normally
// do not need to call this function, unless you want to tweak the native
// window.
Dispatch(f func())
// Destroy destroys a webview and closes the native window.
Destroy()
// Window returns a native window handle pointer. When using GTK backend the
// pointer is GtkWindow pointer, when using Cocoa backend the pointer is
// NSWindow pointer, when using Win32 backend the pointer is HWND pointer.
Window() unsafe.Pointer
// SetTitle updates the title of the native window. Must be called from the UI
// thread.
SetTitle(title string)
// SetSize updates native window size. See Hint constants.
SetSize(w int, h int, hint Hint)
// URI. Examples:
// w.Navigate("https://github.com/webview/webview")
// w.Navigate("data:text/html,%3Ch1%3EHello%3C%2Fh1%3E")
// w.Navigate("data:text/html;base64,PGgxPkhlbGxvPC9oMT4=")
Navigate(url string)
// SetHtml sets the webview HTML directly.
// Example: w.SetHtml(w, "<h1>Hello</h1>");
SetHtml(html string)
// Init injects JavaScript code at the initialization of the new page. Every
// time the webview will open a new page - this initialization code will
// be executed. It is guaranteed that code is executed before window.onload.
Init(js string)
// Eval evaluates arbitrary JavaScript code. Evaluation happens asynchronously,
// also the result of the expression is ignored. Use RPC bindings if you want
// to receive notifications about the results of the evaluation.
Eval(js string)
// Bind binds a callback function so that it will appear under the given name
// as a global JavaScript function. Internally it uses webview_init().
// Callback receives a request string and a user-provided argument pointer.
// Request string is a JSON array of all the arguments passed to the
// JavaScript function.
//
// f must be a function
// f must return either value and error or just error
Bind(name string, f interface{}) error
// SetUserAgent sets a custom user agent string for the webview.
SetUserAgent(userAgent string)
// SetWindowEventsHandler sets the window status change event handling function
// Should be called before calling the "Run" method
// Example:
// w.SetWindowEventsHandler("test", func(state webview.WindowState) {
// switch state {
// case webview.WindowClose:
// w.Hide()
// case webview.WindowResize:
// // Example: save window size for restore in next launch
// case webview.WindowMove:
// // Example: save window position for restore in next launch
// }
// })
SetWindowEventsHandler(key string, f func(state WindowState))
// UnSetWindowEventsHandler unsets the window status change event handling function
UnSetWindowEventsHandler(key string)
// IsExistWindowEventsHandler checks if this event handler exists
IsExistWindowEventsHandler(key string) bool
// GetTitle gets the title of the native window.
GetTitle() string
// Hide hides the native window.
Hide()
// Show shows the native window.
Show()
// SetBorderless activates the borderless mode.
SetBorderless()
// SetBordered activates the bordered mode.
SetBordered()
// IsMaximized If the native window is maximized it returns true, otherwise false.
IsMaximized() bool
// Maximize maximizes the native window.
Maximize()
// Unmaximize unmaximizes the native window.
Unmaximize()
// IsMinimized If the native window is minimized it returns true, otherwise false.
// IsMinimized Does not work with Stage Manager (MacOS)
IsMinimized() bool
// Minimize minimizes the native window.
Minimize()
// Unminimize unminimizes the native window.
Unminimize()
// IsVisible If the native window is visible it returns true, otherwise false.
IsVisible() bool
// SetFullScreen activates the full-screen mode.
SetFullScreen()
// ExitFullScreen exits full-screen mode.
ExitFullScreen()
// IsFullScreen If the native window is in full-screen mode it returns true, otherwise false.
IsFullScreen() bool
// SetIcon sets the application icon (from filename).
// Example:
// w.SetIcon("icon.png")
SetIcon(icon string) error
// SetIconBites sets the application icon (from []byte).
// Example:
// iconData, err = os.ReadFile("icon.png")
// w.SetIconBites(iconData, len(iconData))
SetIconBites(b []byte, size int)
// SetAlwaysOnTop activates (=true) / deactivates(=false) the top-most mode.
SetAlwaysOnTop(onTop bool)
// GetSize gets the size of the native window.
GetSize() (width int, height int, hint Hint)
// GetPosition gets the coordinates of the native window.
GetPosition() (x, y int)
// Move moves the native window to the specified coordinates.
Move(x, y int)
// Focus set the focus on the native window.
Focus()
// SetContentStateHandler sets the document status change event handling function
// Should be called before calling the "Run" method
// Example:
// w.SetContentStateHandler("test", func(state string) {
// fmt.Printf("document content state: %s\n", state)
// })
// Status of the document:
// uninitialized - Has not started loading
// loading - Is loading
// loaded - Has been loaded
// interactive - Has loaded enough to interact with
// complete - Fully loaded
SetContentStateHandler(key string, f func(state string))
// UnSetContentStateHandler unsets the document status change event handling function
UnSetContentStateHandler(key string)
// IsExistContentStateHandler checks if this event handler exists
IsExistContentStateHandler(key string) bool
// SetDraggable converts a given DOM element to a draggable region. The user will be able to drag the native window by dragging the given DOM element.
// This feature is suitable to make custom window bars along with the borderless mode.
SetDraggable(id string)
// UnSetDraggable converts a draggable region to a normal DOM elements by removing drag event handlers.
UnSetDraggable(id string)
// OpenUrlInBrowser Opens the specified link in the web browser
OpenUrlInBrowser(url string) (err error)
// Just for an example of using the Bind function. See js.go and init.js
GetHtml() (s string)
GetUrl() string
GetPageTitle() string
}
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
|
|
|
bind
command
|
|
|
draggable
command
|
|
|
systray
command
|
|
|
pkg
|
|
|
dialog
Package dialog provides a simple cross-platform common dialog API.
|
Package dialog provides a simple cross-platform common dialog API. |
|
systray
Package systray is a cross-platform Go library to place an icon and menu in the notification area.
|
Package systray is a cross-platform Go library to place an icon and menu in the notification area. |
|
systray/example
command
|
|
|
systray/webview_example
command
|
Click to show internal directories.
Click to hide internal directories.