Comments (7)
I managed to resolve this by calling the MoveFocus method of ICoreWebView2Controller
. But not sure if:
- the library should make an assumption that focus should land on the browser by default;
- the library should just offer a
FocusBrowser
method or similar; and/or - where to put this method call in the code.
I feel that, if the window is being created by the library as opposed to by the caller, as the browser will be the only thing in that window, it is the most accessible approach to have the library focus the browser by default.
from go-webview2.
Also, an additional note: while I can get focus to reliably move into the browser when the window is initially created, I can't get it to stay there. If I Alt+Tab to another window and then back, focus lands on the window again.
from go-webview2.
Sorry about this one. As far as I can tell, the most "correct" solution is simply make use of the very poorly named user32.IsDialogMessage
in order to use the built-in Windows tab handling, which WebView2 can then use to give "correct" tab behavior.
The default event loop has been adjusted to do exactly this.
from go-webview2.
@jchv Thanks, this certainly fixes the case of not being able to Tab/Shift+Tab into the webview once created. But it is still desirable to:
- automatically place focus inside the webview when it is the only descendant of the window; and/or
- allow users of the library to programmatically set focus inside it.
Additionally, some of the problematic behaviour is still present, specifically:
while I can get focus to reliably move into the browser when the window is initially created, I can't get it to stay there. If I Alt+Tab to another window and then back, focus lands on the window again.
If focus is inside the webview when the user switches away from the window, it should also still be there when they switch back.
from go-webview2.
Understood. We can call MoveFocus on WM_ACTIVATE, which would probably accomplish what you are looking for. The change that was added is still useful since it allows us to have focus move from the window to the webview, if, for example, the user were to click the title bar explicitly. I'll take a look at it later today when I am off work and have a moment.
from go-webview2.
@jchv Thanks, sounds good.
from go-webview2.
It might be hard to fully resolve this issue, though at least it's a lot better than it was. I think the keyboard focus behavior should probably simply make sense by default, but for now I have put the new behavior behind an option, AutoFocus
, which will cause go-webview2
to attempt to focus the Webview2 widget whenever the window is focused (including on initialization.) This may need to be tweaked as it is definitely not perfect, but I think it is closer.
from go-webview2.
Related Issues (20)
- How can I do js binding HOT 2
- Using CGO_ENABLED=1 causes GetAvailableCoreWebView2BrowserVersionString to crash HOT 2
- Capture Navigation Events HOT 2
- webviewloader.GetInstalledVersion bugs HOT 2
- Eval in Asynchronous thread not work HOT 1
- js window.talk No voice
- [Feature request] No way to close the window (without user interaction)
- How to solve the cross domain problem of js? HOT 4
- How to get the newer version of WebView2Loader.dll HOT 2
- Add option to show window initially maximized
- Print API
- InPrivate or Incognito mode? HOT 2
- Can we capture the WebSocket message exchange by using go-webview to open a URL containing a WebSocket connection?
- Unable to access local file resources (like images...)
- How to create and use the environmentCompletedHandle
- tag version
- MSHTML for Windows HOT 5
- binary tranfer
- w.Bind() and w.Init() not working on first page load HOT 4
- response headers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-webview2.