Welcome Guest Search | Active Topics | Sign In | Register

Focus Issues with EO.WebBrowser 19.x Options
Stefan Koell
Posted: Monday, March 4, 2019 5:15:28 AM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
Hi,

the 19.x releases do not allow me to focus the web browser control by code. In my app I send keyboard events to fill forms and to ensure the browser has the input focus, I used to call EO.WinForm.WebControl.Focus() method. That worked great in the 18.x versions but not anymore.

I also tried EO.WinForm.WebControl.WebView.SetFocus(). There I can see very shortly that the textbox is focused but after half a second or so the focus is lost again.

Is this a known issue or is there a workaround?

Thanks!
eo_support
Posted: Monday, March 4, 2019 9:08:35 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

We are not aware of such issues, can you create a test project and send it to us? See here for more details:

https://www.essentialobjects.com/forum/test_project.aspx

Thanks
Stefan Koell
Posted: Tuesday, March 5, 2019 3:16:05 AM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
Thanks for looking into this. I just sent you a test project.
eo_support
Posted: Sunday, March 10, 2019 11:06:31 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Thanks for the test project. This is just to let you know that we have resolved the issue on our end. The fix will be in our next build and we will reply here again when the new build is available.
eo_support
Posted: Friday, March 15, 2019 7:54:08 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

This is just to let you know that the new build with the fix is out on our download page. Please take a look and let us know if it resolves the issue for you.

Thanks!
James
Posted: Monday, March 18, 2019 1:09:25 PM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2015
Posts: 122
I seem to now be experiencing this issue in the latest build. I'm working on analyzing it but so far I haven't determined the root cause. Is it possible to get a run down of what that test project was doing?
eo_support
Posted: Monday, March 18, 2019 2:09:40 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

The test project for this particular problem was simply calling WebControl.Focus(). It supposes to set the focus to the first focusable element in the web page. However this did not work properly in the previous build.

The focus management actually is quite complicated because it involves many different scenarios such as tab into, shift tab into, setting focus programmatically (the original problem for this thread), activating the window and automatically setting focus (for example, if the WebView is in the only control in the form and user activate the form), automatically restoring focus to the WebControl (such as after closing a message box), etc. All these different scenarios each have Windows Forms and WPF variations. We have managed to make most of these cases work but there are a few cases we have not been able to find a clean solution yet. For example, after activating a WPF menu and restoring focus to the WebControl still does not work properly. But generally focus should work pretty well for most cases.

If you can provide more details on exactly what happens in your scenario we would be happy to investigate further to see what we can do.

Thanks!
James
Posted: Tuesday, March 19, 2019 8:46:26 AM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2015
Posts: 122
Okay, this definitely isn't the same issue. I'm running int o a problem where clicking into the webview isn't focusing a textbox clicked into most of the time. I'm still investigating, but I'll open a new thread for this once I have details.
eo_support
Posted: Tuesday, March 19, 2019 10:23:45 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
No problem. We will be happy to look further once you have the details.
Stefan Koell
Posted: Wednesday, April 3, 2019 10:17:37 AM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
I finally was able to test the latest bits and there's still something weird going on with the focus management. In my app, I have a VS like UI with a tree on one side and a tabbed interface on the other side. Once the page has been loaded, I call a method which invokes the WebControl.Focus() method. The interesting thing is, if I initiate this process from the toolbar button, it works and the web control and the first element on the web page receives the focus. If I use the double-click event in the tree view, which in the end invokes the very same methods, it does not get the focus. Any idea what the issue here might be? Do I have to do something else in addition to get the focus transferred to the web control?
Stefan Koell
Posted: Wednesday, April 3, 2019 10:35:10 AM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
Ok, I did some more testing and have a pattern which is reproducible. The focus (and simulated keyboard input) is delayed. So when I hit "Go", it loads a page, when the page is ready, the control is focused and the keyboard simulation starts. This takes a second or two. So, if I move the mouse over the web control before the Focus() method is invoked, the control receives the focus. If I do not move the mouse over the web control, the Focus() method does not work. I can send you a video of the behavior if needed.

Regards,
Stefan
eo_support
Posted: Wednesday, April 3, 2019 6:05:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

This maybe related to the current focus node. There are two level of focus with the WebView: Whether the WebView has focus and which node is the current focus node. When the document is just loaded, it has no current focus node. In that case keyboard events will still be directed to the WebView (for example, document.onkeydown will fire when a key is pressed down) when the WebView has focus, however because there is no focus node, you won't see any visual indication where the document in fact has focus.

There are a few different ways the document can gain a focus node:

1. If you press tab key then it will automatically focus the first focusable node;
2. If you mouse click any focusable element (such as a link) then that node will be focused;
3. A focus node can also be set through JavaScript;

There are several different methods you can call for focus:
1. WebControl.Focus only set the focus to the WebView but does not change current focus node. So if no element has never been focused in the document and you call WebControl.Focus, then the WebView will gain focus but you won't see any visual indication that it in fact has focus because no focusable node is selected;
2. WebView.SetFocus(true) is similar to WebControl.Focus;
3. WebView.SetFocus(false) will explicitly set the focus node to the first focusable node in the document. This call might be what you need. So please try this option and see if it works for you. To make sure focus related states are properly updated for WPF, I recommend you to call WebControl.Focus() first, then call WebView.SetFocus(false).

Please let us know if this resolves the issue for you.

Thanks!
Stefan Koell
Posted: Thursday, April 4, 2019 9:19:57 AM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
Thanks for the additional information. Unfortunately it still behaves strangely (only works when the mouse hovers over the control). You write: To make sure focus related states are properly updated for WPF, I recommend you to call WebControl.Focus() first, then call WebView.SetFocus(false). I've done that but it still doesn't work. FWIW, my app is a WinForms app. Not sure if this matters.

Regards,
Stefan
eo_support
Posted: Thursday, April 4, 2019 9:43:12 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
We tested the "mouse over" case in both WPF and Windows Forms and we did not notice the issue you described in either platform. The only thing we noticed is the focused node that may give you the false impression of the WebView not being focused. Windows Forms focus management is in fact slightly simpler than WPF because each control has its own window. So I am not sure what else to tell you. If you wish us to investigate further, you can create a test app for us and we will be happy to debug through it and see what we can find. A video won't help much because it does not clearly tell us what's actually happening in the code.
Stefan Koell
Posted: Thursday, April 4, 2019 9:44:42 AM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
Ok, I will try to get a test app to you to repro the issue... Thanks!
Stefan Koell
Posted: Thursday, April 4, 2019 2:24:46 PM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
Hi!

I just submitted another test project which shows the weird focus behavior.

Regards,
Stefan
eo_support
Posted: Tuesday, April 9, 2019 5:24:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Thanks for the test project. We have found the root of the problem. This will be fixed in our next build.
eo_support
Posted: Friday, April 12, 2019 9:54:52 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

This is just to let you know that we have posted a new build that should resolve this issue. You can download it from our download page. Please take a look and let us know how it goes.

Thanks!
Stefan Koell
Posted: Saturday, April 13, 2019 7:36:32 AM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
I just tested the new release and it seems to work now as expected. Thanks for fixing these issues!
eo_support
Posted: Saturday, April 13, 2019 9:44:55 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Great. Thanks for confirming the fix!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.