WEP Number: 0001
Status: Implemented
Author: Lea Anthony
Created: 2024-05-20
Proposal: #3508
Implementor: Lea Anthony
This is a proposal for an API to control the appearance and functionality of window controls in Wails. This will only be available on Windows and macOS.
We currently do not fully support the ability to customise window controls.
- A new enum will be added:
type ButtonState int
const (
ButtonEnabled ButtonState = 0
ButtonDisabled ButtonState = 1
ButtonHidden ButtonState = 2
)- These options will be added to the
WebviewWindowOptionsoption struct:
MinimiseButtonState ButtonState
MaximiseButtonState ButtonState
CloseButtonState ButtonState- These options will be removed from the current Windows/Mac options:
- DisableMinimiseButton
- DisableMaximiseButton
- DisableCloseButton
- These methods will be added to the
Windowinterface:
SetMinimizeButtonState(state ButtonState)
SetMaximizeButtonState(state ButtonState)
SetCloseButtonState(state ButtonState)The settings translate to the following functionality on each platform:
| Windows | Mac | |
|---|---|---|
| Disable Min/Max/Close | Disables Min/Max/Close | Disables Min/Max/Close |
| Hide Min | Disables Min | Hides Min button |
| Hide Max | Disables Max | Hides Max button |
| Hide Close | Hides all controls | Hides Close |
Note: On Windows, it is not possible to hide the Min/Max buttons individually. However, disabling both will hide both of the controls and only show the close button.
As Windows currently does not have much in the way of controlling the style of the
titlebar, a new option will be added to the WebviewWindowOptions option struct:
ExStyle intIf this is set, then the new Window will use the style specified in the ExStyle field.
Example:
package main
import (
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/w32"
)
func main() {
app := application.New(application.Options{
Name: "My Application",
})
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Windows: application.WindowsWindow{
ExStyle: w32.WS_EX_TOOLWINDOW | w32.WS_EX_NOREDIRECTIONBITMAP | w32.WS_EX_TOPMOST,
},
})
app.Run()
}- We bring much needed customisation capabilities to both macOS and Windows
- Windows works slightly different to macOS
- No Linux support (doesn't look like it's possible regardless of the solution)
The alternative is to draw your own titlebar, but this is a lot of work and often doesn't look good.
This is not backwards compatible as we remove the old "disable button" options.
As part of the implementation, the window example will be updated to test the functionality.
There is a reference implementation as part of this proposal.
This feature will be maintained and supported by the Wails developers.
This API would be a leap forward in giving developers greater control over their application window appearances.