5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 19:39:59 +08:00
wails/mkdocs-website/docs/en/API/application_window.md
2024-03-18 20:47:33 +11:00

1.5 KiB

NewWebviewWindow

API: NewWebviewWindow() *WebviewWindow

NewWebviewWindow() creates a new Webview window with default options, and returns it.

    // Create a new webview window
    window := app.NewWebviewWindow()

NewWebviewWindowWithOptions

API: NewWebviewWindowWithOptions(windowOptions WebviewWindowOptions) *WebviewWindow

NewWebviewWindowWithOptions() creates a new webview window with custom options. The newly created window is added to a map of windows managed by the application.

    // Create a new webview window with custom options
    window := app.NewWebviewWindowWithOptions(WebviewWindowOptions{
		Name: "Main",
        Title: "My Window",
        Width: 800,
        Height: 600,
    })

OnWindowCreation

API: OnWindowCreation(callback func(window *WebviewWindow))

OnWindowCreation() registers a callback function to be called when a window is created.

    // Register a callback to be called when a window is created
    app.OnWindowCreation(func(window *WebviewWindow) {
        // Do something
    })

GetWindowByName

API: GetWindowByName(name string) *WebviewWindow

GetWindowByName() fetches and returns a window with a specific name.

    // Get a window by name
    window := app.GetWindowByName("Main")

CurrentWindow

API: CurrentWindow() *WebviewWindow

CurrentWindow() fetches and returns a pointer to the currently active window in the application. If there is no window, it returns nil.

    // Get the current window
    window := app.CurrentWindow()