Compare commits

...

66 Commits

Author SHA1 Message Date
Misite Bao 7670273d43 feat(website): init the website 2023-05-30 16:57:54 +08:00
Lea Anthony a15c0a5441 [v3] Website skeleton 2023-05-30 16:56:35 +08:00
Lea Anthony 19be7f61ac [v3 windows] Fix resizing. Add resize debouncing 2023-05-30 16:36:00 +08:00
Misite Bao bbf0e8cdad chore: split Taskfile (#2654) 2023-05-30 16:35:59 +08:00
Lea Anthony 7e2d2a29a1 [v3 windows] Initial webview2 working 2023-05-30 16:33:34 +08:00
Lea Anthony 671dc2aa3a [v3 windows] Implement start x/y + parent window for dialogs 2023-05-30 16:33:34 +08:00
Lea Anthony 294a2c701e [v3] Update esbuild 2023-05-30 16:33:34 +08:00
Lea Anthony 01f03c552d [v3] Improve invoke 2023-05-30 16:33:33 +08:00
Lea Anthony dc46154d94 [v3 mac] Support drag 2023-05-30 16:33:33 +08:00
Lea Anthony 87737c23eb [v3 mac] DisableWindowShadow -> DisableShadow 2023-05-30 16:33:33 +08:00
Lea Anthony 6e6f099a99 [v3 mac] Basic common event support. Taskfile refactor 2023-05-30 16:33:32 +08:00
Lea Anthony 4cb3321c39 [v3 mac] Update README 2023-05-30 16:32:02 +08:00
Lea Anthony 6a2343a1a0 [v3 mac] Add DisableWindowShadow option 2023-05-30 16:32:01 +08:00
Lea Anthony f2d6dba2cf [v3 windows] initial dialog support. Refactor button callback name 2023-05-30 16:32:01 +08:00
stffabi dd1ef7fae9 [v3 darwin] Add darwin identifier darwin only file 2023-05-30 16:32:01 +08:00
stffabi 527cff9ec3 [v3 darwin] Add darwin identifier to all C files of darwin 2023-05-30 16:32:00 +08:00
stffabi ba150eccae [v3 windows] Add close handling: HideOnClose, QuitOnLastWindowClosed and DisableQuitOnLastWindowClosed 2023-05-30 16:32:00 +08:00
Travis McLane fa74986f1e [v3 example] menu text toggle 2023-05-30 16:32:00 +08:00
Travis McLane d1085b5bea [v3 example] add menuitem.Hidden / setHidden example 2023-05-30 16:31:59 +08:00
Travis McLane 4d0a14d2eb [v3 darwin] menuitem.setHidden implementation 2023-05-30 16:31:59 +08:00
Travis McLane 8c3439b733 [dialogs] remove default title
without this removal a user would have to call `SetTitle("")` in order to
erase the default if they desire a title-less dialog.
2023-05-30 16:31:59 +08:00
stffabi a0534d527a [v3 application] Fix race conditions between starting a window/systray and starting the application
Make sure a window is never run before the windowCreated hooks have been executed.
2023-05-30 16:31:59 +08:00
Lea Anthony a5b52f2795 [v3 windows] initial systray support 2023-05-30 16:31:58 +08:00
Lea Anthony b526ebd679 [v3 mac] Update api. New template icon. 2023-05-30 16:31:58 +08:00
Lea Anthony 51b9315ae9 [v3 windows] update status 2023-05-30 16:31:58 +08:00
Lea Anthony 8edf44dc31 [v3 windows] New icons 2023-05-30 16:31:57 +08:00
Lea Anthony 9b7626e59e [v3 windows] Move icons to own package, systray dark mode icon, window.Focus(), 2023-05-30 16:31:57 +08:00
Lea Anthony 6dd092c7a9 [v3 windows] Rename systray callback handlers 2023-05-30 16:31:57 +08:00
Lea Anthony 46a0d467c0 [v3 windows] Dialogs to use invokeSync 2023-05-30 16:31:56 +08:00
Lea Anthony e3b164ae93 [v3 windows] Systray callback handlers 2023-05-30 16:31:56 +08:00
stffabi d8f58ab20f [v3 windows] Fix wndproc default case with WMMessageToString 2023-05-30 16:31:56 +08:00
stffabi 0de2bccd28 [v3 windows] Do not disable WndProc messaging for systray when updating icon 2023-05-30 16:31:55 +08:00
Lea Anthony 2eaf724710 [v3 windows] Fix systray icon size 2023-05-30 16:31:55 +08:00
Lea Anthony 58138ac09b [v3 windows] Initial systray support 2023-05-30 16:31:55 +08:00
Lea Anthony 143f090422 [v3] Use invokeSync for systray methods 2023-05-30 16:31:55 +08:00
Lea Anthony f8f466ba7e [v3 windows] Support irregular shaped windows. Centered option. 2023-05-30 16:31:54 +08:00
Lea Anthony cb28de47f8 [v3 windows] Support irregular shaped windows 2023-05-30 16:31:54 +08:00
stffabi 4ad2475ed6 [v3] Add some missing methods for darwin and windows 2023-05-30 16:31:54 +08:00
Travis McLane 0172078536 [w32] move windows specific code to impl file 2023-05-30 16:31:53 +08:00
Travis McLane 0bb1fb512a [w32] add missing build constraint 2023-05-30 16:31:53 +08:00
Lea Anthony b6940d95a2 [v3 windows] Add frameless resize 2023-05-30 16:31:53 +08:00
stffabi 75f0457375 [v3 windows] Add HiDPI awareness 2023-05-30 16:31:52 +08:00
stffabi ffe31b6265 [v3 windows] Add frameless support 2023-05-30 16:31:52 +08:00
Lea Anthony 8963610722 [v3 windows] Implement getScreen 2023-05-30 16:31:52 +08:00
Lea Anthony 66bfcf0e36 [v3] Ensure impl calls from WebvieWindow are on the main thread. Support size. 2023-05-30 16:31:52 +08:00
Lea Anthony 0b3559abfe [v3] Fix examples 2023-05-30 16:31:51 +08:00
Lea Anthony 773389ee5e [v3] Update examples to use correct options. 2023-05-30 16:31:51 +08:00
Lea Anthony 4c04991d4d [v3] Change WebviewWindow options to be a value, not a pointer. Support Un/Fullscreen. Remove main thread switching. Use parent options instead of local variables. 2023-05-30 16:31:51 +08:00
Lea Anthony d56bb59b72 [v3 Windows] Support application hide/show. Add WebviewWindow.IsVisible(). 2023-05-30 16:31:50 +08:00
Lea Anthony 6e92a4f71e [v3 Windows] Support setMin/MaxSize, setPosition 2023-05-30 16:31:50 +08:00
Lea Anthony 1f6217c0d8 [v3 Windows] Add Support for SetTitle, Center, Un/Minimise/Maximise, IsMin/Maximised, IsNormal, Show/Hide 2023-05-30 16:31:50 +08:00
Lea Anthony 17204bebd0 [v3 Breaking Change] Add NativeWindowHandle method to WebviewWindow. 2023-05-30 16:31:49 +08:00
Lea Anthony 728e2019d8 [v3 windows] Moved w32 from internal to pkg so it may be used by applications 2023-05-30 16:31:49 +08:00
Lea Anthony 7f3fdd6977 [v3 windows] Add WndProcInterceptor for custom message processing 2023-05-30 16:31:49 +08:00
Lea Anthony e8798f8371 [v3 windows] Rename options_windows.go -> options_win.go 2023-05-30 16:31:48 +08:00
Lea Anthony 402b743553 [v3 windows] Add APM Events 2023-05-30 16:31:48 +08:00
Lea Anthony f08ae2fc62 [v3] Update application.On and window.On to return functions that unregister the listener. WebviewWindow.onApplicationEvent is a helper which will manage the unregistering for you on window destroy. 2023-05-30 16:31:48 +08:00
Lea Anthony 178ea9c8c5 [windows] Split out wndProc. Generate windows events, support per-window themes 2023-05-30 16:31:48 +08:00
Lea Anthony 7c63cee9e8 [windows] Support AlwaysOnTop, EnableResize at runtime. Added Solid/Transparent/Translucent options. 2023-05-30 16:31:47 +08:00
stffabi 4a60dfc373 [v3, windows] Add MainThread dispatching and fixes the blocking window 2023-05-30 16:31:47 +08:00
Lea Anthony 829a829cb4 [windows] WIP 2023-05-30 16:31:47 +08:00
Travis McLane 34896ccb4e [darwin] add getPrimaryScreen/getScreens to impl (#2618) 2023-05-30 16:31:46 +08:00
Lea Anthony 5df5eb6a04 Fix module path for non-modified repo 2023-05-30 16:31:46 +08:00
Lea Anthony 31ba36baf3 [windows] Initial commit 2023-05-30 16:31:46 +08:00
Lea Anthony bf10f71760 [windows] Fix paths for wails init 2023-05-30 16:31:45 +08:00
Lea Anthony 8aa61fff6d Intial STATUS.md commit 2023-05-30 16:31:45 +08:00
203 changed files with 16242 additions and 1007 deletions
+1
View File
@@ -6,3 +6,4 @@ cmd/wails/wails
/examples/menu/menu
/examples/clipboard/clipboard
/examples/plain/plain
/website/venv/
+315
View File
@@ -0,0 +1,315 @@
# Status
Status of features in v3. Incomplete - please add as you see fit.
## Application
Application interface methods
| Method | Windows | Linux | Mac | Notes |
|---------------------------------------------------------------|---------|-------|-----|-------|
| run() error | | | Y | |
| destroy() | | | Y | |
| setApplicationMenu(menu *Menu) | | | Y | |
| name() string | | | Y | |
| getCurrentWindowID() uint | | | Y | |
| showAboutDialog(name string, description string, icon []byte) | | | Y | |
| setIcon(icon []byte) | | | Y | |
| on(id uint) | | | Y | |
| dispatchOnMainThread(fn func()) | Y | | Y | |
| hide() | Y | | Y | |
| show() | Y | | Y | |
| getPrimaryScreen() (*Screen, error) | | | Y | |
| getScreens() ([]*Screen, error) | | | Y | |
## Webview Window
Webview Window Interface Methods
| Method | Windows | Linux | Mac | Notes |
|----------------------------------------------------|---------|-------|-----|------------------------------------------|
| center() | Y | | Y | |
| close() | | | Y | |
| destroy() | | | Y | |
| execJS(js string) | | | Y | |
| focus() | Y | | Y | |
| forceReload() | | | Y | |
| fullscreen() | Y | | Y | |
| getScreen() (*Screen, error) | | | Y | |
| getZoom() float64 | | | Y | |
| height() int | Y | | Y | |
| hide() | Y | | Y | |
| isFullscreen() bool | Y | | Y | |
| isMaximised() bool | Y | | Y | |
| isMinimised() bool | Y | | Y | |
| maximise() | Y | | Y | |
| minimise() | Y | | Y | |
| nativeWindowHandle() (uintptr, error) | Y | | Y | |
| on(eventID uint) | | | Y | |
| openContextMenu(menu *Menu, data *ContextMenuData) | | | Y | |
| position() (int, int) | Y | | Y | |
| reload() | | | Y | |
| run() | Y | | Y | |
| setAlwaysOnTop(alwaysOnTop bool) | Y | | Y | |
| setBackgroundColour(color RGBA) | Y | | Y | |
| setFrameless(bool) | | | Y | |
| setFullscreenButtonEnabled(enabled bool) | - | | Y | There is no fullscreen button in Windows |
| setHTML(html string) | | | Y | |
| setMaxSize(width, height int) | Y | | Y | |
| setMinSize(width, height int) | Y | | Y | |
| setPosition(x int, y int) | Y | | Y | |
| setResizable(resizable bool) | Y | | Y | |
| setSize(width, height int) | Y | | Y | |
| setTitle(title string) | Y | | Y | |
| setURL(url string) | | | Y | |
| setZoom(zoom float64) | | | Y | |
| show() | Y | | Y | |
| size() (int, int) | Y | | Y | |
| toggleDevTools() | | | Y | |
| unfullscreen() | Y | | Y | |
| unmaximise() | Y | | Y | |
| unminimise() | Y | | Y | |
| width() int | Y | | Y | |
| zoom() | | | Y | |
| zoomIn() | | | Y | |
| zoomOut() | | | Y | |
| zoomReset() | | | Y | |
## Runtime
### Application
| Feature | Windows | Linux | Mac | Notes |
|---------|---------|-------|-----|-------|
| Quit | | | Y | |
| Hide | Y | | Y | |
| Show | Y | | Y | |
### Dialogs
| Feature | Windows | Linux | Mac | Notes |
|----------|---------|-------|-----|-------|
| Info | Y | | Y | |
| Warning | Y | | Y | |
| Error | Y | | Y | |
| Question | Y | | Y | |
| OpenFile | Y | | Y | |
| SaveFile | Y | | Y | |
### Clipboard
| Feature | Windows | Linux | Mac | Notes |
|---------|---------|-------|-----|-------|
| SetText | | | Y | |
| Text | | | Y | |
### ContextMenu
| Feature | Windows | Linux | Mac | Notes |
|-----------------|---------|-------|-----|-------|
| OpenContextMenu | | | Y | |
### Screens
| Feature | Windows | Linux | Mac | Notes |
|------------|---------|-------|-----|-------|
| GetAll | Y | | Y | |
| GetPrimary | | | Y | |
| GetCurrent | | | Y | |
### Window
| Feature | Windows | Linux | Mac | Notes |
|---------------------|---------|-------|-----|--------------------------------------------------------------------------------------|
| SetTitle | Y | | Y | |
| SetSize | Y | | Y | |
| Size | Y | | Y | |
| SetPosition | Y | | Y | |
| Position | Y | | Y | |
| Focus | Y | | Y | |
| FullScreen | Y | | Y | |
| UnFullscreen | Y | | Y | |
| Minimise | Y | | Y | |
| UnMinimise | Y | | Y | |
| Maximise | Y | | Y | |
| UnMaximise | Y | | Y | |
| Show | Y | | Y | |
| Hide | Y | | Y | |
| Center | Y | | Y | |
| SetBackgroundColour | Y | | Y | https://github.com/MicrosoftEdge/WebView2Feedback/issues/1621#issuecomment-938234294 |
| SetAlwaysOnTop | Y | | Y | |
| SetResizable | Y | | Y | |
| SetMinSize | Y | | Y | |
| SetMaxSize | Y | | Y | |
| Width | Y | | Y | |
| Height | Y | | Y | |
| ZoomIn | | | Y | Increase view scale |
| ZoomOut | | | Y | Decrease view scale |
| ZoomReset | | | Y | Reset view scale |
| GetZoom | | | Y | Get current view scale |
| SetZoom | | | Y | Set view scale |
| Screen | | | Y | Get screen for window |
### Window Options
A 'Y' in the table below indicates that the option has been tested and is applied when the window is created.
An 'X' indicates that the option is not supported by the platform.
| Feature | Windows | Linux | Mac | Notes |
|---------------------------------|---------|-------|-----|--------------------------------------------|
| Name | Y | | | |
| Title | Y | | | |
| Width | Y | | | |
| Height | Y | | | |
| AlwaysOnTop | Y | | | |
| URL | | | | |
| DisableResize | Y | | | |
| Frameless | Y | | | |
| MinWidth | Y | | | |
| MinHeight | Y | | | |
| MaxWidth | Y | | | |
| MaxHeight | Y | | | |
| StartState | Y | | | |
| Mac | - | - | | |
| BackgroundType | | | | Acrylic seems to work but the others don't |
| BackgroundColour | Y | | | |
| HTML | | | | |
| JS | | | | |
| CSS | | | | |
| X | Y | | | |
| Y | Y | | | |
| HideOnClose | Y | | | |
| FullscreenButtonEnabled | Y | | | |
| Hidden | Y | | | |
| EnableFraudulentWebsiteWarnings | | | | |
| Zoom | | | | |
| ZoomControlEnabled | | | | |
| OpenInspectorOnStartup | | | | |
| EnableDragAndDrop | | | | |
| Windows | Y | - | - | |
| Focused | Y | | | |
### Log
To log or not to log? System logger vs custom logger.
## Menu
| Event | Windows | Linux | Mac | Notes |
|--------------------------|---------|-------|-----|-------|
| Default Application Menu | | | Y | |
## Tray Menus
| Feature | Windows | Linux | Mac | Notes |
|--------------------|---------|-------|-----|----------------------------------------------------------------------|
| Icon | Y | | Y | Windows has default icons for light/dark mode & supports PNG or ICO. |
| Label | - | | Y | |
| Label (ANSI Codes) | - | | | |
| Menu | Y | | Y | |
## Cross Platform Events
Mapping native events to cross-platform events.
| Event | Windows | Linux | Mac | Notes |
|--------------------------|---------|-------|-----------------|-------|
| WindowWillClose | | | WindowWillClose | |
| WindowDidClose | | | | |
| WindowDidResize | | | | |
| WindowDidHide | | | | |
| ApplicationWillTerminate | | | | |
... Add more
## Bindings Generation
TBD
## Models Generation
TBD
## Task file
TBD
## Theme
| Mode | Windows | Linux | Mac | Notes |
|--------|---------|-------|-----|-------|
| Dark | Y | | | |
| Light | Y | | | |
| System | Y | | | |
## NSIS Installer
TBD
## Templates
TBD
## Plugins
Built-in plugin support:
| Plugin | Windows | Linux | Mac | Notes |
|-----------------|---------|-------|-----|-------|
| Browser | | | Y | |
| KV Store | | | Y | |
| Log | | | Y | |
| Single Instance | | | Y | |
| SQLite | | | Y | |
| Start at login | | | Y | |
| Server | | | | |
## Packaging
| | Windows | Linux | Mac | Notes |
|-----------------|---------|-------|-----|-------|
| Icon Generation | | | Y | |
| Icon Embedding | | | Y | |
| Info.plist | - | | Y | |
| NSIS Installer | | | - | |
| Mac bundle | | | Y | |
| Windows exe | | | - | |
## Frameless Windows
| Feature | Windows | Linux | Mac | Notes |
|---------|---------|-------|-----|-------|
| Resize | | | | |
| Drag | | | | |
## Mac Specific
- [x] Translucency
### Mac Options
| Feature | Default | Notes |
|-------------------------|-------------------|------------------------------------------------------|
| Backdrop | MacBackdropNormal | Standard solid window |
| DisableShadow | false | |
| TitleBar | | Standard window decorations by default |
| Appearance | DefaultAppearance | |
| InvisibleTitleBarHeight | 0 | Creates an invisible title bar for frameless windows |
## Windows Specific
- [x] Translucency
- [x] Custom Themes
### Windows Options
| Feature | Default | Notes |
|-----------------------------------|---------|---------------------------------------------|
| BackdropType | | |
| DisableIcon | | |
| Theme | | |
| CustomTheme | | |
| DisableFramelessWindowDecorations | | |
| WindowMask | nil | Makes the window the contents of the bitmap |
## Linux Specific
-49
View File
@@ -1,49 +0,0 @@
# TODO
Informal and incomplete list of things needed in v3.
## General
- [x] Generate Bindings
- [x] Generate TS Models
- [ ] Dev Mode
- [ ] Generate Info.Plist from `info.json`
- [ ] Windows Port
- [ ] Linux Port
## Runtime
- [x] Pass window ID with window calls in JS
- [x] Implement alias for `window` in JS
- [x] Implement runtime dispatcher
- [x] Log
- [x] Same Window
- [ ] Other Window
- [x] Dialogs
- [x] Info
- [x] Warning
- [x] Error
- [x] Question
- [x] OpenFile
- [x] SaveFile
- [x] Events
- [x] Screens
- [x] Clipboard
- [x] Application
- [ ] Create `.d.ts` file
## Templates
- [ ] Create plain template
- [ ] Improve default template
## Runtime
- [ ] To log or not to log?
- [ ] Unify cross-platform events, eg. `onClose`
## Plugins
- [ ] Move logins to `v3/plugins`
- [ ] Expose application logger to plugins
+25 -128
View File
@@ -3,124 +3,16 @@
version: "3"
includes:
runtime:
taskfile: ./internal/runtime
dir: ./internal/runtime
website:
taskfile: ./website
dir: ./website
optional: true
tasks:
build-runtime-debug:
dir: internal/runtime
internal: true
cmds:
- npx esbuild desktop/main.js --bundle --sourcemap=inline --outfile=runtime_debug_desktop_{{.PLATFORM}}.js --define:DEBUG=true --define:WINDOWS={{.WINDOWS}} --define:DARWIN={{.DARWIN}} --define:LINUX={{.LINUX}} --define:PLATFORM={{.PLATFORM}}
build-runtime-debug-windows:
cmds:
- task: build-runtime-debug
vars:
WINDOWS: true
DARWIN: false
LINUX: false
PLATFORM: windows
build-runtime-debug-linux:
cmds:
- task: build-runtime-debug
vars:
WINDOWS: false
DARWIN: false
LINUX: true
PLATFORM: linux
build-runtime-debug-darwin:
cmds:
- task: build-runtime-debug
vars:
WINDOWS: false
DARWIN: true
LINUX: false
PLATFORM: darwin
build-runtime-production:
dir: internal/runtime
internal: true
cmds:
- npx esbuild desktop/main.js --bundle --minify --outfile=runtime_production_desktop_{{.PLATFORM}}.js --define:DEBUG=true --define:WINDOWS={{.WINDOWS}} --define:DARWIN={{.DARWIN}} --define:LINUX={{.LINUX}} --define:PLATFORM={{.PLATFORM}}
build-runtime-production-windows:
cmds:
- task: build-runtime-production
vars:
WINDOWS: true
DARWIN: false
LINUX: false
PLATFORM: windows
build-runtime-production-linux:
cmds:
- task: build-runtime-production
vars:
WINDOWS: false
DARWIN: false
LINUX: true
PLATFORM: linux
build-runtime-production-darwin:
cmds:
- task: build-runtime-production
vars:
WINDOWS: false
DARWIN: true
LINUX: false
PLATFORM: darwin
install-runtime-dev-deps:
dir: internal/runtime/dev
internal: true
sources:
- package.json
cmds:
- npm install
install-runtime-deps:
dir: internal/runtime
internal: true
sources:
- package.json
cmds:
- npm install
test-runtime:
dir: internal/runtime
cmds:
- npx vitest run
update-runtime:
dir: internal/runtime
cmds:
- npx npm-check-updates -u
build-runtime-all:
dir: internal/runtime
deps:
- build-runtime-production-darwin
- build-runtime-production-windows
- build-runtime-production-linux
- build-runtime-debug-darwin
- build-runtime-debug-windows
- build-runtime-debug-linux
cmds:
- cmd: echo "build complete"
build-runtime:
dir: internal/runtime
deps:
- install-runtime-deps
cmds:
- task: build-runtime-all
recreate-template-dir:
dir: internal/templates
internal: true
@@ -129,7 +21,7 @@ tasks:
- rm -rf {{.TEMPLATE_DIR}}
- mkdir -p {{.TEMPLATE_DIR}}
generate-template:
generate:template:
dir: internal/templates/{{.TEMPLATE}}
deps:
- task: recreate-template-dir
@@ -156,49 +48,54 @@ tasks:
- go install
- echo "Reinstalled wails CLI"
generate-templates:
generate:events:
dir: tasks/events
cmds:
- go run generate.go
generate:templates:
dir: internal/templates/
deps:
- task: generate-template
- task: generate:template
vars:
TEMPLATE: svelte
- task: generate-template
- task: generate:template
vars:
TEMPLATE: svelte-ts
- task: generate-template
- task: generate:template
vars:
TEMPLATE: vue
- task: generate-template
- task: generate:template
vars:
TEMPLATE: vue-ts
- task: generate-template
- task: generate:template
vars:
TEMPLATE: react
- task: generate-template
- task: generate:template
vars:
TEMPLATE: react-ts
- task: generate-template
- task: generate:template
vars:
TEMPLATE: preact
- task: generate-template
- task: generate:template
vars:
TEMPLATE: preact-ts
- task: generate-template
- task: generate:template
vars:
TEMPLATE: lit
- task: generate-template
- task: generate:template
vars:
TEMPLATE: lit-ts
- task: generate-template
- task: generate:template
vars:
TEMPLATE: vanilla
- task: generate-template
- task: generate:template
vars:
TEMPLATE: vanilla-ts
- task: generate-template
- task: generate:template
vars:
TEMPLATE: react-swc
- task: generate-template
- task: generate:template
vars:
TEMPLATE: react-swc-ts
cmds:
+54
View File
@@ -59,6 +59,24 @@ TBD
Dialogs are now available in JavaScript!
### Windows
Dialog buttons in Windows are not configurable and are constant depending on the type of dialog. To trigger a callback when a button is pressed, create a button with the same name as the button you wish to have the callback attached to.
Example: Create a button with the label `Ok` and use `OnClick()` to set the callback method:
```go
dialog := app.QuestionDialog().
SetTitle("Update").
SetMessage("The cancel button is selected when pressing escape")
ok := dialog.AddButton("Ok")
ok.OnClick(func() {
// Do something
})
no := dialog.AddButton("Cancel")
dialog.SetDefaultButton(ok)
dialog.SetCancelButton(no)
dialog.Show()
```
## Drag and Drop
Native drag and drop can be enabled per-window. Simply set the `EnableDragAndDrop` window config option to `true` and the window will allow files to be dragged onto it. When this happens, the `events.FilesDropped` event will be emitted. The filenames can then be retrieved from the WindowEventContext using the `DroppedFiles()` method. This returns a slice of strings containing the filenames.
@@ -180,3 +198,39 @@ const MyEnum = {
- Why use `float64`? Can't we use `int`?
- Because JavaScript doesn't have a concept of `int`. Everything is a `number`, which translates to `float64` in Go. There are also restrictions on casting types in Go's reflection package, which means using `int` doesn't work.
### BackgroundColour
In v2, this was a pointer to an `RGBA` struct. In v3, this is an `RGBA` struct value.
### WindowIsTranslucent
This flag has been removed. Now there is a `BackgroundType` flag that can be used to set the type of background the window should have.
This flag can be set to any of the following values:
- `BackgroundTypeSolid` - The window will have a solid background
- `BackgroundTypeTransparent` - The window will have a transparent background
- `BackgroundTypeTranslucent` - The window will have a translucent background
On Windows, if the `BackgroundType` is set to `BackgroundTypeTranslucent`, the type of translucency can be set using the
`BackdropType` flag in the `WindowsWindow` options. This can be set to any of the following values:
- `Auto` - The window will use an effect determined by the system
- `None` - The window will have no background
- `Mica` - The window will use the Mica effect
- `Acrylic` - The window will use the acrylic effect
- `Tabbed` - The window will use the tabbed effect
## Windows Application Options
### WndProcInterceptor
If this is set, the WndProc will be intercepted and the function will be called. This allows you to handle Windows
messages directly. The function should have the following signature:
```go
func(hwnd uintptr, msg uint32, wParam, lParam uintptr) (returnValue uintptr, shouldReturn)
```
The `shouldReturn` value should be set to `true` if the returnValue should be returned by the main wndProc method.
If it is set to `false`, the return value will be ignored and the message will continue to be processed by the main
wndProc method.
+5
View File
@@ -5,15 +5,20 @@ go 1.20
require github.com/wailsapp/wails/v3 v3.0.0-alpha.0
require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leaanthony/slicer v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/samber/lo v1.37.0 // indirect
github.com/wailsapp/go-webview2 v1.0.1 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6 // indirect
golang.org/x/exp v0.0.0-20220930202632-ec3f01382ef9 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.8.0 // indirect
)
replace github.com/wailsapp/wails/v3 => ../..
+12
View File
@@ -1,7 +1,13 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY=
@@ -18,6 +24,8 @@ github.com/samber/lo v1.37.0/go.mod h1:9vaz2O4o8oOnK23pd2TrXufcbdbJIa3b6cstBWKpo
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/wailsapp/go-webview2 v1.0.1 h1:dEJIeEApW/MhO2tTMISZBFZPuW7kwrFA1NtgFB1z1II=
github.com/wailsapp/go-webview2 v1.0.1/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
golang.org/x/exp v0.0.0-20220930202632-ec3f01382ef9 h1:RjggHMcaTVp0LOVZcW0bo8alwHrOaCrGUDgfWUHhnN4=
@@ -25,8 +33,12 @@ golang.org/x/exp v0.0.0-20220930202632-ec3f01382ef9/go.mod h1:cyybsKvd6eL0RnXn6p
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+4 -3
View File
@@ -19,14 +19,15 @@ func main() {
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Assets: application.AssetOptions{
FS: assets,
},
})
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
URL: "/",
})
err := app.Run()
if err != nil {
+3 -3
View File
@@ -67,7 +67,7 @@ func main() {
if runtime.GOOS == "darwin" {
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInset)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInset,
InvisibleTitleBarHeight: 25,
@@ -81,7 +81,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInsetUnified)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
@@ -95,7 +95,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (MacTitleBarHidden)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHidden,
InvisibleTitleBarHeight: 25,
+2 -2
View File
@@ -25,7 +25,7 @@ func main() {
},
})
mainWindow := app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
mainWindow := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Context Menu Demo",
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
@@ -34,7 +34,7 @@ func main() {
},
})
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Context Menu Demo",
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
+6 -4
View File
@@ -2,6 +2,7 @@ package main
import (
_ "embed"
"github.com/wailsapp/wails/v3/pkg/icons"
"log"
"os"
"runtime"
@@ -19,6 +20,7 @@ func main() {
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create a custom menu
menu := app.NewMenu()
menu.AddRole(application.AppMenu)
@@ -45,7 +47,7 @@ func main() {
dialog := app.InfoDialog()
dialog.SetTitle("Custom Icon Example")
dialog.SetMessage("Using a custom icon")
dialog.SetIcon(application.DefaultApplicationIcon)
dialog.SetIcon(icons.ApplicationDarkMode256)
dialog.Show()
})
@@ -85,7 +87,7 @@ func main() {
dialog := app.QuestionDialog()
dialog.SetTitle("Custom Icon Example")
dialog.SetMessage("Using a custom icon")
dialog.SetIcon(application.WailsLogoWhiteTransparent)
dialog.SetIcon(icons.WailsLogoWhiteTransparent)
dialog.SetDefaultButton(dialog.AddButton("I like it!"))
dialog.AddButton("Not so keen...")
dialog.Show()
@@ -112,7 +114,7 @@ func main() {
dialog := app.WarningDialog()
dialog.SetTitle("Custom Icon Example")
dialog.SetMessage("Using a custom icon")
dialog.SetIcon(application.DefaultApplicationIcon)
dialog.SetIcon(icons.ApplicationLightMode256)
dialog.Show()
})
@@ -137,7 +139,7 @@ func main() {
dialog := app.ErrorDialog()
dialog.SetTitle("Custom Icon Example")
dialog.SetMessage("Using a custom icon")
dialog.SetIcon(application.WailsLogoWhite)
dialog.SetIcon(icons.WailsLogoWhite)
dialog.Show()
})
+1 -1
View File
@@ -25,7 +25,7 @@ func main() {
},
})
window := app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
window := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Drag-n-drop Demo",
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
+9 -2
View File
@@ -26,10 +26,12 @@ func main() {
},
})
// Custom event handling
app.Events.On("myevent", func(e *application.WailsEvent) {
log.Printf("[Go] WailsEvent received: %+v\n", e)
})
// OS specific application events
app.On(events.Mac.ApplicationDidFinishLaunching, func() {
for {
log.Println("Sending event")
@@ -41,7 +43,12 @@ func main() {
}
})
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
// Platform agnostic events
app.On(events.Common.ApplicationStarted, func() {
println("events.Common.ApplicationStarted fired!")
})
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Events Demo",
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
@@ -49,7 +56,7 @@ func main() {
InvisibleTitleBarHeight: 50,
},
})
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Events Demo",
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
+32
View File
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
.container {
display: flex;
flex-wrap: wrap;
height: 100%;
}
.quarter {
flex: 50%; /* This will cause elements to take up 50% of the container's width, causing them to wrap into 4 equal sections. */
box-sizing: border-box; /* This makes the padding part of the element's total width and height, ensuring they don't exceed 50%. */
padding: 20px;
}
</style>
</head>
<body>
<div class="container">
<div class="quarter" style="background-color: lightblue; --wails-draggable: drag">Draggable</div>
<div class="quarter" style="background-color: lightgreen;">Not Draggable</div>
<div class="quarter" style="background-color: lightpink;">Not Draggable</div>
<div class="quarter" style="background-color: lightyellow; --wails-draggable: drag">Draggable</div>
</div>
</body>
</html>
+36
View File
@@ -0,0 +1,36 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed assets
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "Frameless Demo",
Description: "A demo of frameless windows",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
Assets: application.AssetOptions{
FS: assets,
},
})
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Frameless: true,
})
err := app.Run()
if err != nil {
log.Fatal(err.Error())
}
}
+8 -7
View File
@@ -2,6 +2,7 @@ package main
import (
_ "embed"
"github.com/wailsapp/wails/v3/pkg/icons"
"log"
"runtime"
"sync"
@@ -62,9 +63,9 @@ func main() {
mySystray := app.NewSystemTray()
mySystray.SetLabel("Wails")
if runtime.GOOS == "darwin" {
mySystray.SetTemplateIcon(application.DefaultMacTemplateIcon)
mySystray.SetTemplateIcon(icons.SystrayMacTemplate)
} else {
mySystray.SetIcon(application.DefaultApplicationIcon)
mySystray.SetIcon(icons.ApplicationDarkMode256)
}
myMenu := app.NewMenu()
myMenu.Add("Item 1")
@@ -102,20 +103,20 @@ func main() {
mySystray := app.NewSystemTray()
mySystray.SetLabel("Wails is awesome")
if runtime.GOOS == "darwin" {
mySystray.SetTemplateIcon(application.DefaultMacTemplateIcon)
mySystray.SetTemplateIcon(icons.SystrayMacTemplate)
} else {
mySystray.SetIcon(application.DefaultApplicationIcon)
mySystray.SetIcon(icons.ApplicationDarkMode256)
}
mySystray.SetMenu(myMenu)
mySystray.SetIconPosition(application.NSImageLeading)
myWindow := app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
myWindow := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Kitchen Sink",
Width: 600,
Height: 400,
AlwaysOnTop: true,
DisableResize: false,
BackgroundColour: &application.RGBA{
BackgroundColour: application.RGBA{
Red: 255,
Green: 255,
Blue: 255,
@@ -184,7 +185,7 @@ func main() {
*/
var myWindow2 *application.WebviewWindow
var myWindow2Lock sync.RWMutex
myWindow2 = app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
myWindow2 = app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "#2",
Width: 1024,
Height: 768,
+15 -2
View File
@@ -29,7 +29,12 @@ func main() {
// Click callbacks
myMenu.Add("Click Me!").OnClick(func(ctx *application.Context) {
ctx.ClickedMenuItem().SetLabel("Thanks mate!")
switch ctx.ClickedMenuItem().Label() {
case "Click Me!":
ctx.ClickedMenuItem().SetLabel("Thanks mate!")
case "Thanks mate!":
ctx.ClickedMenuItem().SetLabel("Click Me!")
}
})
// You can control the current window from the menu
@@ -82,7 +87,15 @@ func main() {
beatles.SetLabel("Hello")
}
})
myMenu.Add("Hide the beatles").OnClick(func(ctx *application.Context) {
if beatles.Hidden() {
ctx.ClickedMenuItem().SetLabel("Unhide the beatles!")
beatles.SetHidden(false)
} else {
beatles.SetHidden(true)
ctx.ClickedMenuItem().SetLabel("Hide the beatles!")
}
})
app.SetMenu(menu)
app.NewWebviewWindow()
+17 -1
View File
@@ -4,6 +4,7 @@ import (
_ "embed"
"log"
"net/http"
"time"
"github.com/wailsapp/wails/v3/pkg/application"
)
@@ -23,7 +24,7 @@ func main() {
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; user-select: none; -ms-user-select: none; -webkit-user-select: none; } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
@@ -38,6 +39,21 @@ func main() {
println("clicked")
})
go func() {
time.Sleep(5 * time.Second)
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Plain Bundle new Window from GoRoutine",
Width: 500,
Height: 500,
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
},
})
}()
err := app.Run()
if err != nil {
+1 -1
View File
@@ -24,7 +24,7 @@ func main() {
},
})
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Screen Demo",
Width: 800,
Height: 600,
+35 -2
View File
@@ -2,12 +2,21 @@ package main
import (
_ "embed"
"fmt"
"github.com/wailsapp/wails/v3/pkg/icons"
"log"
"runtime"
"github.com/wailsapp/wails/v3/pkg/application"
)
var counter int
func clickCount() int {
counter++
return counter
}
func main() {
app := application.New(application.Options{
Name: "Systray Demo",
@@ -17,26 +26,50 @@ func main() {
},
})
window := app.NewWebviewWindow().Hide()
systemTray := app.NewSystemTray()
if runtime.GOOS == "darwin" {
systemTray.SetIcon(application.DefaultMacTemplateIcon)
systemTray.SetTemplateIcon(icons.SystrayMacTemplate)
}
myMenu := app.NewMenu()
myMenu.Add("Hello World!").OnClick(func(ctx *application.Context) {
app.InfoDialog().SetTitle("Hello World!").SetMessage("Hello World!").Show()
println("Hello World!")
q := app.QuestionDialog().SetTitle("Ready?").SetMessage("Are you feeling ready?")
q.AddButton("Yes").OnClick(func() {
println("Awesome!")
})
q.AddButton("No").SetAsDefault().OnClick(func() {
println("Boo!")
})
q.Show()
})
subMenu := myMenu.AddSubmenu("Submenu")
subMenu.Add("Click me!").OnClick(func(ctx *application.Context) {
ctx.ClickedMenuItem().SetLabel("Clicked!")
})
myMenu.AddSeparator()
myMenu.AddCheckbox("Checked", true).OnClick(func(ctx *application.Context) {
println("Checked: ", ctx.ClickedMenuItem().Checked())
app.InfoDialog().SetTitle("Hello World!").SetMessage("Hello World!").Show()
})
myMenu.Add("Enabled").OnClick(func(ctx *application.Context) {
println("Click me!")
ctx.ClickedMenuItem().SetLabel("Disabled!").SetEnabled(false)
})
myMenu.AddSeparator()
myMenu.Add("Quit").OnClick(func(ctx *application.Context) {
app.Quit()
})
systemTray.SetMenu(myMenu)
systemTray.OnClick(func() {
window.SetTitle(fmt.Sprintf("Clicked %d times", clickCount()))
window.Show().Focus()
})
err := app.Run()
if err != nil {

Some files were not shown because too many files have changed in this diff Show More