mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-15 16:39:32 +08:00
[v3] Add window Enabled
method. Fix dialog attachment
This commit is contained in:
parent
8f075b5d8d
commit
76672facfe
50
v3/STATUS.md
50
v3/STATUS.md
@ -60,6 +60,7 @@ Webview Window Interface Methods
|
||||
| run() | Y | Y | Y | |
|
||||
| setAlwaysOnTop(alwaysOnTop bool) | Y | Y | Y | |
|
||||
| setBackgroundColour(color RGBA) | Y | Y | Y | |
|
||||
| setEnabled(bool) | | Y | Y | |
|
||||
| setFrameless(bool) | | Y | Y | |
|
||||
| setFullscreenButtonEnabled(enabled bool) | - | Y | Y | There is no fullscreen button in Windows |
|
||||
| setHTML(html string) | Y | Y | Y | |
|
||||
@ -135,36 +136,41 @@ Anything nested under a tag with `--default-contextmenu: hide` style will not sh
|
||||
|
||||
### Window
|
||||
|
||||
Y = Supported
|
||||
U = Untested
|
||||
- = Not available
|
||||
|
||||
| Feature | Windows | Linux | Mac | Notes |
|
||||
|---------------------|---------|-------|-----|--------------------------------------------------------------------------------------|
|
||||
| SetTitle | Y | Y | Y | |
|
||||
| SetSize | Y | Y | Y | |
|
||||
| Size | Y | Y | Y | |
|
||||
| SetPosition | Y | Y | Y | |
|
||||
| Position | Y | Y | Y | |
|
||||
| Center | Y | Y | Y | |
|
||||
| Focus | Y | Y | | |
|
||||
| FullScreen | Y | Y | Y | |
|
||||
| UnFullscreen | Y | Y | Y | |
|
||||
| Minimise | Y | Y | Y | |
|
||||
| UnMinimise | Y | Y | Y | |
|
||||
| Maximise | Y | Y | Y | |
|
||||
| UnMaximise | Y | Y | Y | |
|
||||
| Show | Y | Y | Y | |
|
||||
| Hide | Y | Y | Y | |
|
||||
| Center | Y | Y | Y | |
|
||||
| SetBackgroundColour | Y | Y | Y | https://github.com/MicrosoftEdge/WebView2Feedback/issues/1621#issuecomment-938234294 |
|
||||
| SetAlwaysOnTop | Y | Y | Y | |
|
||||
| SetResizable | Y | Y | Y | |
|
||||
| SetMinSize | Y | Y | Y | |
|
||||
| SetMaxSize | Y | Y | Y | |
|
||||
| Width | Y | Y | Y | |
|
||||
| GetZoom | Y | Y | Y | Get current view scale |
|
||||
| Height | Y | Y | Y | |
|
||||
| Hide | Y | Y | Y | |
|
||||
| Maximise | Y | Y | Y | |
|
||||
| Minimise | Y | Y | Y | |
|
||||
| Position | Y | Y | Y | |
|
||||
| Screen | Y | Y | Y | Get screen for window |
|
||||
| SetAlwaysOnTop | Y | Y | Y | |
|
||||
| SetBackgroundColour | Y | Y | Y | https://github.com/MicrosoftEdge/WebView2Feedback/issues/1621#issuecomment-938234294 |
|
||||
| SetEnabled | Y | U | U | Set the window to be enabled/disabled |
|
||||
| SetMaxSize | Y | Y | Y | |
|
||||
| SetMinSize | Y | Y | Y | |
|
||||
| SetPosition | Y | Y | Y | |
|
||||
| SetResizable | Y | Y | Y | |
|
||||
| SetSize | Y | Y | Y | |
|
||||
| SetTitle | Y | Y | Y | |
|
||||
| SetZoom | Y | Y | Y | Set view scale |
|
||||
| Show | Y | Y | Y | |
|
||||
| Size | Y | Y | Y | |
|
||||
| UnFullscreen | Y | Y | Y | |
|
||||
| UnMaximise | Y | Y | Y | |
|
||||
| UnMinimise | Y | Y | Y | |
|
||||
| Width | Y | Y | Y | |
|
||||
| ZoomIn | Y | Y | Y | Increase view scale |
|
||||
| ZoomOut | Y | Y | Y | Decrease view scale |
|
||||
| ZoomReset | Y | Y | Y | Reset view scale |
|
||||
| GetZoom | Y | Y | Y | Get current view scale |
|
||||
| SetZoom | Y | Y | Y | Set view scale |
|
||||
| Screen | Y | Y | Y | Get screen for window |
|
||||
|
||||
### Window Options
|
||||
|
||||
|
@ -294,6 +294,13 @@ func main() {
|
||||
app.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
|
||||
})
|
||||
})
|
||||
stateMenu.Add("Disable for 5s").OnClick(func(ctx *application.Context) {
|
||||
currentWindow(func(w *application.WebviewWindow) {
|
||||
w.SetEnabled(false)
|
||||
time.Sleep(5 * time.Second)
|
||||
w.SetEnabled(true)
|
||||
})
|
||||
})
|
||||
|
||||
printMenu := menu.AddSubmenu("Print")
|
||||
printMenu.Add("Print").OnClick(func(ctx *application.Context) {
|
||||
|
@ -199,7 +199,6 @@ func showCfdDialog(newDlg func() (cfd.Dialog, error), isMultiSelect bool) (any,
|
||||
}
|
||||
}()
|
||||
|
||||
dlg.SetParentWindowHandle(0)
|
||||
if multi, _ := dlg.(cfd.OpenMultipleFilesDialog); multi != nil && isMultiSelect {
|
||||
return multi.ShowAndGetResults()
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ type (
|
||||
startDrag() error
|
||||
startResize(border string) error
|
||||
print() error
|
||||
setEnabled(enabled bool)
|
||||
}
|
||||
)
|
||||
|
||||
@ -922,3 +923,12 @@ func (w *WebviewWindow) Print() error {
|
||||
}
|
||||
return invokeSyncWithError(w.impl.print)
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) SetEnabled(enabled bool) {
|
||||
if w.impl == nil {
|
||||
return
|
||||
}
|
||||
invokeSync(func() {
|
||||
w.impl.setEnabled(enabled)
|
||||
})
|
||||
}
|
||||
|
@ -664,7 +664,11 @@ static void windowPrint(void *window) {
|
||||
// [printOperation runOperation] DOES NOT WORK WITH WKWEBVIEW, use
|
||||
[po runOperationModalForWindow:window delegate:windowDelegate didRunSelector:nil contextInfo:nil];
|
||||
}
|
||||
}
|
||||
|
||||
void setWindowEnabled(void *window, bool enabled) {
|
||||
WebviewWindow* nsWindow = (WebviewWindow*)window;
|
||||
[nsWindow setIgnoresMouseEvents:!enabled];
|
||||
}
|
||||
|
||||
*/
|
||||
@ -868,6 +872,10 @@ func (w *macosWebviewWindow) restoreWindow() {
|
||||
C.windowRestore(w.nsWindow)
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) setEnabled(enabled bool) {
|
||||
C.windowSetEnabled(w.nsWindow, C.bool(enabled))
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) execJS(js string) {
|
||||
C.windowExecJS(w.nsWindow, C.CString(js))
|
||||
}
|
||||
|
@ -348,6 +348,12 @@ func (w *linuxWebviewWindow) fullscreen() {
|
||||
})
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) setEnabled(enabled bool) {
|
||||
globalApplication.dispatchOnMainThread(func() {
|
||||
C.gtk_widget_set_sensitive((*C.GtkWidget)(w.window), C.gboolean(enabled))
|
||||
})
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) unminimise() {
|
||||
C.gtk_window_present((*C.GtkWindow)(w.window))
|
||||
// gtk_window_unminimize ((*C.GtkWindow)(w.window)) /// gtk4
|
||||
|
@ -195,6 +195,14 @@ func (w *linuxWebviewWindow) unfullscreen() {
|
||||
})
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) setEnabled(enabled bool) {
|
||||
var gtkWidgetSensitive func(uintptr, int)
|
||||
purego.RegisterLibFunc(>kWidgetSensitive, gtk, "gtk_widget_set_sensitive")
|
||||
globalApplication.dispatchOnMainThread(func() {
|
||||
gtkWidgetSensitive(w.window, boolToInt(enabled))
|
||||
})
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) fullscreen() {
|
||||
var fullScreen func(uintptr)
|
||||
purego.RegisterLibFunc(&fullScreen, gtk, "gtk_window_fullscreen")
|
||||
|
@ -63,6 +63,10 @@ type windowsWebviewWindow struct {
|
||||
resizeBorderHeight int32
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) setEnabled(enabled bool) {
|
||||
w32.EnableWindow(w.hwnd, enabled)
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) print() error {
|
||||
w.execJS("window.print();")
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user