@@ -3,6 +3,7 @@ package main
3
3
import (
4
4
_ "embed"
5
5
"fmt"
6
+ "github.com/wailsapp/wails/v3/pkg/w32"
6
7
"log"
7
8
"math/rand"
8
9
"runtime"
@@ -64,12 +65,7 @@ func main() {
64
65
myMenu .Add ("New WebviewWindow (Disable Minimise)" ).
65
66
OnClick (func (ctx * application.Context ) {
66
67
app .NewWebviewWindowWithOptions (application.WebviewWindowOptions {
67
- Windows : application.WindowsWindow {
68
- DisableMinimiseButton : true ,
69
- },
70
- Mac : application.MacWindow {
71
- DisableMinimiseButton : true ,
72
- },
68
+ MinimiseButtonState : application .ButtonDisabled ,
73
69
}).
74
70
SetTitle ("WebviewWindow " + strconv .Itoa (windowCounter )).
75
71
SetRelativePosition (rand .Intn (1000 ), rand .Intn (800 )).
@@ -80,12 +76,29 @@ func main() {
80
76
myMenu .Add ("New WebviewWindow (Disable Maximise)" ).
81
77
OnClick (func (ctx * application.Context ) {
82
78
app .NewWebviewWindowWithOptions (application.WebviewWindowOptions {
83
- Windows : application.WindowsWindow {
84
- DisableMaximiseButton : true ,
85
- },
86
- Mac : application.MacWindow {
87
- DisableMaximiseButton : true ,
88
- },
79
+ MaximiseButtonState : application .ButtonDisabled ,
80
+ }).
81
+ SetTitle ("WebviewWindow " + strconv .Itoa (windowCounter )).
82
+ SetRelativePosition (rand .Intn (1000 ), rand .Intn (800 )).
83
+ SetURL ("https://wails.io" ).
84
+ Show ()
85
+ windowCounter ++
86
+ })
87
+ myMenu .Add ("New WebviewWindow (Hide Minimise)" ).
88
+ OnClick (func (ctx * application.Context ) {
89
+ app .NewWebviewWindowWithOptions (application.WebviewWindowOptions {
90
+ MinimiseButtonState : application .ButtonHidden ,
91
+ }).
92
+ SetTitle ("WebviewWindow " + strconv .Itoa (windowCounter )).
93
+ SetRelativePosition (rand .Intn (1000 ), rand .Intn (800 )).
94
+ SetURL ("https://wails.io" ).
95
+ Show ()
96
+ windowCounter ++
97
+ })
98
+ myMenu .Add ("New WebviewWindow (Hide Maximise)" ).
99
+ OnClick (func (ctx * application.Context ) {
100
+ app .NewWebviewWindowWithOptions (application.WebviewWindowOptions {
101
+ MaximiseButtonState : application .ButtonHidden ,
89
102
}).
90
103
SetTitle ("WebviewWindow " + strconv .Itoa (windowCounter )).
91
104
SetRelativePosition (rand .Intn (1000 ), rand .Intn (800 )).
@@ -94,13 +107,22 @@ func main() {
94
107
windowCounter ++
95
108
})
96
109
}
97
- if runtime .GOOS == "darwin" {
110
+ if runtime .GOOS == "darwin" || runtime . GOOS == "windows" {
98
111
myMenu .Add ("New WebviewWindow (Disable Close)" ).
99
112
OnClick (func (ctx * application.Context ) {
100
113
app .NewWebviewWindowWithOptions (application.WebviewWindowOptions {
101
- Mac : application.MacWindow {
102
- DisableCloseButton : true ,
103
- },
114
+ CloseButtonState : application .ButtonDisabled ,
115
+ }).
116
+ SetTitle ("WebviewWindow " + strconv .Itoa (windowCounter )).
117
+ SetRelativePosition (rand .Intn (1000 ), rand .Intn (800 )).
118
+ SetURL ("https://wails.io" ).
119
+ Show ()
120
+ windowCounter ++
121
+ })
122
+ myMenu .Add ("New WebviewWindow (Hide Close)" ).
123
+ OnClick (func (ctx * application.Context ) {
124
+ app .NewWebviewWindowWithOptions (application.WebviewWindowOptions {
125
+ CloseButtonState : application .ButtonHidden ,
104
126
}).
105
127
SetTitle ("WebviewWindow " + strconv .Itoa (windowCounter )).
106
128
SetRelativePosition (rand .Intn (1000 ), rand .Intn (800 )).
@@ -110,6 +132,22 @@ func main() {
110
132
})
111
133
112
134
}
135
+ if runtime .GOOS == "windows" {
136
+ myMenu .Add ("New WebviewWindow (Custom ExStyle)" ).
137
+ OnClick (func (ctx * application.Context ) {
138
+ app .NewWebviewWindowWithOptions (application.WebviewWindowOptions {
139
+ Windows : application.WindowsWindow {
140
+ DisableMenu : true ,
141
+ ExStyle : w32 .WS_EX_TOOLWINDOW | w32 .WS_EX_NOREDIRECTIONBITMAP | w32 .WS_EX_TOPMOST ,
142
+ },
143
+ }).
144
+ SetTitle ("WebviewWindow " + strconv .Itoa (windowCounter )).
145
+ SetRelativePosition (rand .Intn (1000 ), rand .Intn (800 )).
146
+ SetURL ("https://wails.io" ).
147
+ Show ()
148
+ windowCounter ++
149
+ })
150
+ }
113
151
114
152
myMenu .Add ("New WebviewWindow (Hides on Close one time)" ).
115
153
SetAccelerator ("CmdOrCtrl+H" ).
@@ -278,12 +316,6 @@ func main() {
278
316
w .SetMinSize (200 , 200 )
279
317
})
280
318
})
281
- sizeMenu .Add ("Set Max Size (600,600)" ).OnClick (func (ctx * application.Context ) {
282
- currentWindow (func (w * application.WebviewWindow ) {
283
- w .SetFullscreenButtonEnabled (false )
284
- w .SetMaxSize (600 , 600 )
285
- })
286
- })
287
319
sizeMenu .Add ("Get Current WebviewWindow Size" ).OnClick (func (ctx * application.Context ) {
288
320
currentWindow (func (w * application.WebviewWindow ) {
289
321
width , height := w .Size ()
@@ -297,12 +329,6 @@ func main() {
297
329
})
298
330
})
299
331
300
- sizeMenu .Add ("Reset Max Size" ).OnClick (func (ctx * application.Context ) {
301
- currentWindow (func (w * application.WebviewWindow ) {
302
- w .SetMaxSize (0 , 0 )
303
- w .SetFullscreenButtonEnabled (true )
304
- })
305
- })
306
332
positionMenu := menu .AddSubmenu ("Position" )
307
333
positionMenu .Add ("Set Relative Position (0,0)" ).OnClick (func (ctx * application.Context ) {
308
334
currentWindow (func (w * application.WebviewWindow ) {
@@ -346,6 +372,52 @@ func main() {
346
372
w .Center ()
347
373
})
348
374
})
375
+ titleBarMenu := menu .AddSubmenu ("Controls" )
376
+ titleBarMenu .Add ("Disable Minimise" ).OnClick (func (ctx * application.Context ) {
377
+ currentWindow (func (w * application.WebviewWindow ) {
378
+ w .SetMinimiseButtonState (application .ButtonDisabled )
379
+ })
380
+ })
381
+ titleBarMenu .Add ("Enable Minimise" ).OnClick (func (ctx * application.Context ) {
382
+ currentWindow (func (w * application.WebviewWindow ) {
383
+ w .SetMinimiseButtonState (application .ButtonEnabled )
384
+ })
385
+ })
386
+ titleBarMenu .Add ("Hide Minimise" ).OnClick (func (ctx * application.Context ) {
387
+ currentWindow (func (w * application.WebviewWindow ) {
388
+ w .SetMinimiseButtonState (application .ButtonHidden )
389
+ })
390
+ })
391
+ titleBarMenu .Add ("Disable Maximise" ).OnClick (func (ctx * application.Context ) {
392
+ currentWindow (func (w * application.WebviewWindow ) {
393
+ w .SetMaximiseButtonState (application .ButtonDisabled )
394
+ })
395
+ })
396
+ titleBarMenu .Add ("Enable Maximise" ).OnClick (func (ctx * application.Context ) {
397
+ currentWindow (func (w * application.WebviewWindow ) {
398
+ w .SetMaximiseButtonState (application .ButtonEnabled )
399
+ })
400
+ })
401
+ titleBarMenu .Add ("Hide Maximise" ).OnClick (func (ctx * application.Context ) {
402
+ currentWindow (func (w * application.WebviewWindow ) {
403
+ w .SetMaximiseButtonState (application .ButtonHidden )
404
+ })
405
+ })
406
+ titleBarMenu .Add ("Disable Close" ).OnClick (func (ctx * application.Context ) {
407
+ currentWindow (func (w * application.WebviewWindow ) {
408
+ w .SetCloseButtonState (application .ButtonDisabled )
409
+ })
410
+ })
411
+ titleBarMenu .Add ("Enable Close" ).OnClick (func (ctx * application.Context ) {
412
+ currentWindow (func (w * application.WebviewWindow ) {
413
+ w .SetCloseButtonState (application .ButtonEnabled )
414
+ })
415
+ })
416
+ titleBarMenu .Add ("Hide Close" ).OnClick (func (ctx * application.Context ) {
417
+ currentWindow (func (w * application.WebviewWindow ) {
418
+ w .SetCloseButtonState (application .ButtonHidden )
419
+ })
420
+ })
349
421
stateMenu := menu .AddSubmenu ("State" )
350
422
stateMenu .Add ("Minimise (for 2 secs)" ).OnClick (func (ctx * application.Context ) {
351
423
currentWindow (func (w * application.WebviewWindow ) {
0 commit comments