mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[v3] Restore ToggleMaximise method in Window interface (#3281)
* Add JS Window API example * Add ToggleMaximise button to Window API example * Restore ToggleMaximise method in Window interface * Update docs and changelog
This commit is contained in:
@@ -298,6 +298,7 @@ import "github.com/wailsapp/wails/v3/pkg/application"
|
||||
- [func \(w \*WebviewWindow\) Size\(\) \(int, int\)](#WebviewWindow.Size)
|
||||
- [func \(w \*WebviewWindow\) ToggleDevTools\(\)](#WebviewWindow.ToggleDevTools)
|
||||
- [func \(w \*WebviewWindow\) ToggleFullscreen\(\)](#WebviewWindow.ToggleFullscreen)
|
||||
- [func \(w \*WebviewWindow\) ToggleMaximise\(\)](#WebviewWindow.ToggleMaximise)
|
||||
- [func \(w \*WebviewWindow\) UnFullscreen\(\)](#WebviewWindow.UnFullscreen)
|
||||
- [func \(w \*WebviewWindow\) UnMaximise\(\)](#WebviewWindow.UnMaximise)
|
||||
- [func \(w \*WebviewWindow\) UnMinimise\(\)](#WebviewWindow.UnMinimise)
|
||||
@@ -3715,6 +3716,16 @@ func (w *WebviewWindow) ToggleFullscreen()
|
||||
|
||||
ToggleFullscreen toggles the window between fullscreen and normal
|
||||
|
||||
<a name="WebviewWindow.ToggleMaximise"></a>
|
||||
|
||||
### func \(\*WebviewWindow\) [ToggleMaximise](https://github.com/wailsapp/wails/blob/master/v3/pkg/application/webview_window.go#L720)
|
||||
|
||||
```go
|
||||
func (w *WebviewWindow) ToggleMaximise()
|
||||
```
|
||||
|
||||
ToggleMaximise toggles the window between maximised and normal
|
||||
|
||||
<a name="WebviewWindow.UnFullscreen"></a>
|
||||
|
||||
### func \(\*WebviewWindow\) [UnFullscreen](https://github.com/wailsapp/wails/blob/master/v3/pkg/application/webview_window.go#L859)
|
||||
|
||||
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- [linux] add task `run:linux` by [@marcus-crane](https://github.com/marcus-crane) in [#3146](https://github.com/wailsapp/wails/pull/3146)
|
||||
- export `SetIcon` method by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3147)
|
||||
- Improve `OnShutdown` by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3189)
|
||||
- restore `ToggleMaximise` method in `Window` interface by [@fbbdev](https://github.com/fbbdev) in [#3281](https://github.com/wailsapp/wails/pull/3281)
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Window API Example
|
||||
|
||||
This is an example of how to use the JS Window API
|
||||
|
||||
## Running the example
|
||||
|
||||
To run the example, simply run the following command:
|
||||
|
||||
```bash
|
||||
go run .
|
||||
```
|
||||
|
||||
# Status
|
||||
|
||||
| Platform | Status |
|
||||
|----------|---------|
|
||||
| Mac | Working |
|
||||
| Windows | |
|
||||
| Linux | |
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"log"
|
||||
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
)
|
||||
|
||||
//go:embed assets/*
|
||||
var assets embed.FS
|
||||
|
||||
func main() {
|
||||
|
||||
app := application.New(application.Options{
|
||||
Name: "JS Window API Demo",
|
||||
Description: "A demo of the JS Window API",
|
||||
Mac: application.MacOptions{
|
||||
ApplicationShouldTerminateAfterLastWindowClosed: true,
|
||||
},
|
||||
Assets: application.AssetOptions{
|
||||
Handler: application.AssetFileServerFS(assets),
|
||||
},
|
||||
})
|
||||
|
||||
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||
Title: "JS Window API Demo",
|
||||
Width: 1280,
|
||||
Height: 1024,
|
||||
Mac: application.MacWindow{
|
||||
Backdrop: application.MacBackdropTranslucent,
|
||||
TitleBar: application.MacTitleBarHiddenInsetUnified,
|
||||
InvisibleTitleBarHeight: 50,
|
||||
},
|
||||
})
|
||||
|
||||
err := app.Run()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -36,6 +36,7 @@ tasks:
|
||||
|
||||
cmds:
|
||||
- cmd: wails3 tool cp ../commands/build_assets/runtime/runtime.js ../../examples/frameless/assets/runtime.js
|
||||
- cmd: wails3 tool cp ../commands/build_assets/runtime/runtime.js ../../examples/window-api/assets/runtime.js
|
||||
- cmd: wails3 tool cp ../commands/build_assets/runtime/runtime.js ../../examples/wml/assets/runtime.js
|
||||
- cmd: wails3 tool cp ../commands/build_assets/runtime/runtime.js ../../internal/commands/build_assets/runtime/runtime.js
|
||||
- cmd: wails3 tool cp ../commands/build_assets/runtime/runtime.js ../../pkg/application/assets/alpha/runtime.js
|
||||
@@ -50,4 +51,4 @@ tasks:
|
||||
generate:events:
|
||||
dir: ../../tasks/events
|
||||
cmds:
|
||||
- go run generate.go
|
||||
- go run generate.go
|
||||
|
||||
@@ -12,16 +12,16 @@ import (
|
||||
// as parameter through every function call.
|
||||
|
||||
const (
|
||||
callRequest int = 0
|
||||
clipboardRequest = 1
|
||||
applicationRequest = 2
|
||||
eventsRequest = 3
|
||||
contextMenuRequest = 4
|
||||
dialogRequest = 5
|
||||
windowRequest = 6
|
||||
screensRequest = 7
|
||||
systemRequest = 8
|
||||
browserRequest = 9
|
||||
callRequest = 0
|
||||
clipboardRequest = 1
|
||||
applicationRequest = 2
|
||||
eventsRequest = 3
|
||||
contextMenuRequest = 4
|
||||
dialogRequest = 5
|
||||
windowRequest = 6
|
||||
screensRequest = 7
|
||||
systemRequest = 8
|
||||
browserRequest = 9
|
||||
)
|
||||
|
||||
type MessageProcessor struct {
|
||||
|
||||
@@ -123,6 +123,9 @@ func (m *MessageProcessor) processWindowMethod(method int, rw http.ResponseWrite
|
||||
case WindowUnMaximise:
|
||||
window.UnMaximise()
|
||||
m.ok(rw)
|
||||
case WindowToggleMaximise:
|
||||
window.ToggleMaximise()
|
||||
m.ok(rw)
|
||||
case WindowRestore:
|
||||
window.Restore()
|
||||
m.ok(rw)
|
||||
|
||||
@@ -803,6 +803,20 @@ func (w *WebviewWindow) ToggleFullscreen() {
|
||||
})
|
||||
}
|
||||
|
||||
// ToggleMaximise toggles the window between maximised and normal
|
||||
func (w *WebviewWindow) ToggleMaximise() {
|
||||
if w.impl == nil && !w.isDestroyed() {
|
||||
return
|
||||
}
|
||||
InvokeSync(func() {
|
||||
if w.IsMaximised() {
|
||||
w.UnMaximise()
|
||||
} else {
|
||||
w.Maximise()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) ToggleDevTools() {
|
||||
if w.impl == nil && !w.isDestroyed() {
|
||||
return
|
||||
|
||||
@@ -67,6 +67,7 @@ type Window interface {
|
||||
Size() (width int, height int)
|
||||
ToggleDevTools()
|
||||
ToggleFullscreen()
|
||||
ToggleMaximise()
|
||||
UnFullscreen()
|
||||
UnMaximise()
|
||||
UnMinimise()
|
||||
|
||||
@@ -217,6 +217,8 @@ func (w Window) ToggleDevTools() {
|
||||
|
||||
func (w Window) ToggleFullscreen() {}
|
||||
|
||||
func (w Window) ToggleMaximise() {}
|
||||
|
||||
func (w Window) UnFullscreen() {}
|
||||
|
||||
func (w Window) UnMaximise() {}
|
||||
|
||||
Reference in New Issue
Block a user