v3/wep/proposals/titlebar-buttons/proposal.md
Author: Lea Anthony Created: 2024-05-20
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.
type ButtonState int
const (
ButtonEnabled ButtonState = 0
ButtonDisabled ButtonState = 1
ButtonHidden ButtonState = 2
)
WebviewWindowOptions option struct: MinimiseButtonState ButtonState
MaximiseButtonState ButtonState
CloseButtonState ButtonState
Window interface: 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 int
If 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()
}
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.