diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 68e79c91..c1b5f4aa 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -42,4 +42,5 @@ Wails is what it is because of the time and effort given by these great people.
* [misitebao](https://github.com/misitebao)
* [Elie Grenon](https://github.com/DrunkenPoney)
* [SophieAu](https://github.com/SophieAu)
- * [Alexander Matviychuk](https://github.com/alexmat)
\ No newline at end of file
+ * [Alexander Matviychuk](https://github.com/alexmat)
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 5c279e02..f6fb2509 100644
--- a/README.md
+++ b/README.md
@@ -150,7 +150,8 @@ This project was mainly coded to the following albums:
## Special Thanks
- A *huge* thanks to
Pace for sponsoring the project and helping the efforts to get Wails ported to Apple Silicon!
+ 
+ A *huge* thanks to Pace for sponsoring the project and helping the efforts to get Wails ported to Apple Silicon!
If you are looking for a Project Management tool that's powerful but quick and easy to use, check them out!
diff --git a/cmd/version.go b/cmd/version.go
index 0a15b77f..721809d5 100644
--- a/cmd/version.go
+++ b/cmd/version.go
@@ -2,3 +2,4 @@ package cmd
// Version - Wails version
const Version = "v1.12.0-pre4"
+
diff --git a/lib/renderer/webview.go b/lib/renderer/webview.go
index c51e76bc..1c0ff73a 100644
--- a/lib/renderer/webview.go
+++ b/lib/renderer/webview.go
@@ -256,6 +256,9 @@ func (w *WebView) SelectFile(title string, filter string) string {
wg.Done()
})
}()
+
+ defer w.focus() // Ensure the main window is put back into focus afterwards
+
wg.Wait()
return result
}
@@ -274,6 +277,9 @@ func (w *WebView) SelectDirectory() string {
wg.Done()
})
}()
+
+ defer w.focus() // Ensure the main window is put back into focus afterwards
+
wg.Wait()
return result
}
@@ -292,10 +298,20 @@ func (w *WebView) SelectSaveFile(title string, filter string) string {
wg.Done()
})
}()
+
+ defer w.focus() // Ensure the main window is put back into focus afterwards
+
wg.Wait()
return result
}
+// focus puts the main window into focus
+func (w *WebView) focus() {
+ w.window.Dispatch(func() {
+ w.window.Focus()
+ })
+}
+
// callback sends a callback to the frontend
func (w *WebView) callback(data string) error {
callbackCMD := fmt.Sprintf("window.wails._.Callback('%s');", data)
diff --git a/lib/renderer/webview/webview.go b/lib/renderer/webview/webview.go
index e9a760ab..0e5da75c 100755
--- a/lib/renderer/webview/webview.go
+++ b/lib/renderer/webview/webview.go
@@ -65,6 +65,10 @@ static inline void CgoWebViewSetTitle(void *w, char *title) {
webview_set_title((struct webview *)w, title);
}
+static inline void CgoWebViewFocus(void *w) {
+ webview_focus((struct webview *)w);
+}
+
static inline void CgoWebViewSetFullscreen(void *w, int fullscreen) {
webview_set_fullscreen((struct webview *)w, fullscreen);
}
@@ -170,6 +174,10 @@ type WebView interface {
// SetTitle() changes window title. This method must be called from the main
// thread only. See Dispatch() for more details.
SetTitle(title string)
+
+ // Focus() puts the main window into focus
+ Focus()
+
// SetFullscreen() controls window full-screen mode. This method must be
// called from the main thread only. See Dispatch() for more details.
SetFullscreen(fullscreen bool)
@@ -307,6 +315,10 @@ func (w *webview) SetColor(r, g, b, a uint8) {
C.CgoWebViewSetColor(w.w, C.uint8_t(r), C.uint8_t(g), C.uint8_t(b), C.uint8_t(a))
}
+func (w *webview) Focus() {
+ C.CgoWebViewFocus(w.w)
+}
+
func (w *webview) SetFullscreen(fullscreen bool) {
C.CgoWebViewSetFullscreen(w.w, C.int(boolToInt(fullscreen)))
}
diff --git a/lib/renderer/webview/webview.h b/lib/renderer/webview/webview.h
index c08cb479..17e0e424 100644
--- a/lib/renderer/webview/webview.h
+++ b/lib/renderer/webview/webview.h
@@ -168,6 +168,7 @@ struct webview_priv
WEBVIEW_API int webview_eval(struct webview *w, const char *js);
WEBVIEW_API int webview_inject_css(struct webview *w, const char *css);
WEBVIEW_API void webview_set_title(struct webview *w, const char *title);
+ WEBVIEW_API void webview_focus(struct webview *w);
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen);
WEBVIEW_API void webview_set_color(struct webview *w, uint8_t r, uint8_t g,
uint8_t b, uint8_t a);
@@ -396,6 +397,11 @@ struct webview_priv
gtk_window_set_title(GTK_WINDOW(w->priv.window), title);
}
+ WEBVIEW_API void webview_focus(struct webview *w)
+ {
+ gtk_window_present(GTK_WINDOW(w->priv.window))
+ }
+
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
{
if (fullscreen)
@@ -1641,6 +1647,11 @@ struct webview_priv
#endif
}
+ WEBVIEW_API void webview_focus(struct webview *w)
+ {
+ SetFocus(w->priv.hwnd);
+ }
+
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
{
if (w->priv.is_fullscreen == !!fullscreen)
@@ -2208,6 +2219,11 @@ struct webview_priv
[w->priv.window setTitle:nsTitle];
}
+ WEBVIEW_API void webview_focus(struct webview *w)
+ {
+ [w->priv.window makeKeyWindow];
+ }
+
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
{
int b = ((([w->priv.window styleMask] & NSWindowStyleMaskFullScreen) ==