Welcome Guest Search | Active Topics | Sign In | Register

WebBrowser - How to activate popup window [WinForms] Options
Stefan Koell
Posted: Wednesday, January 22, 2014 11:38:45 AM
Rank: Advanced Member
Groups: Member

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

I'm handling the NewWindow event to place a web view in a new form (using WinForms). I then try to handle the Activate event to find that window (as shown in the sample app) but I fail to set the input focus to the found window/web view.

So far I've tried something like this.
Code: C#
private void WebView_Activate(object sender, EventArgs e)
        {
            for (int i = 0; i < _PopupWindows.Count; i++)
            {
                if (object.Equals((_PopupWindows[i].Controls[0] as ChromeBrowserEx).Browser.WebView, sender))
                {
                    _PopupWindows[i].BeginInvoke(new MethodInvoker(() =>
                        {
                            _PopupWindows[i].Activate();
                            _PopupWindows[i].Focus();
                            (_PopupWindows[i].Controls[0] as ChromeBrowserEx).Browser.Focus();
                            (_PopupWindows[i].Controls[0] as ChromeBrowserEx).Browser.WebView.SetFocus();
                        }));
                    break;
                }
            }
        }


The window is found, it will also show up as foreground window but the original web view (where the link was clicked) still has the keyboard input.

cheers,
Stefan
eo_support
Posted: Wednesday, January 22, 2014 5:40:19 PM
Rank: Administration
Groups: Administration

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

Your code looks fine. As to focus, the only call you need is WebView.SetFocus(). You do not need to call Focus on the form or on the WebControl. You do need to make sure the form is visible first. As a test, you can try _PopupWindows[i].Show() instead of _PopupWindows[i].Activate(). You may also want to use a timer instead of a BeginInvoke to delay the call to SetFocus because Windows timer message takes a lower priority than other messages.

Hope this helps. Please let us know if it works for you.

Thanks!
Stefan Koell
Posted: Thursday, January 23, 2014 5:08:26 AM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
Thank you for your response!

Unfortunately I'm still not able to get the input focus to the external form after the link (which is opening the popup) is clicked.

Here's the test page I'm using:

http://www.destrucsaweb.com/ressources/phpmyannu/goto_36.php"> http://www.destrucsaweb.com/ressources/phpmyannu/goto_36.php

At the bottom there's a link which opens a popup. No matter what I try (even tried the timer with a 2 sec. delay), the keyboard focus stays on the original webview.

Regards.
Stefan
eo_support
Posted: Thursday, January 23, 2014 8:31:52 AM
Rank: Administration
Groups: Administration

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

Can you try to isolate the problem into a test app and send the test app to us? We will PM you as to where to send.

Thanks!
eo_support
Posted: Friday, January 24, 2014 4:33:46 PM
Rank: Administration
Groups: Administration

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

We have looked into your code. The root of the problem is because your _PopupWindows is not declared as static. As a result, each instance of Form1 has a its own copy of _PopupWindows. The sequence of events based on your code would be:

1. Instance A of Form1 loads the initial page;
2. You click a link in instance A to open a new page;
3. NewWindow is fired, here you create instance B of Form1, and add B into A._PopupWindows;
4. You click the same link in instance A again;
5. The browser engine fires Activate event on instance B's WebView since this is the WebView to be activated;
6. Instance B has its own copy of _PopupWindows which is empty;
7. When Instace B searches its own _PopupWindows, it can not find a match, thus the focus code is not called at all;

To fix the problem, you need to declare _PopupWindows as static or as a "global" variable somewhere else. The key is there can be only one _PopupWindows in your application.

Hope this helps.

Thanks!
Stefan Koell
Posted: Saturday, January 25, 2014 4:40:25 AM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
Thank you for your comments. I did modify the application and created a static list of popup windows but it's still not working. I'm also not sure if this the issue I have in my main application as the setup there is slightly different (but hard to repro in a sample application). The thing is, that in my main application, I can find the view and I can bring the window up (top form) but I'm not able to set the keyboard focus to the web view. It seems that the main view (where I click the link) is forcing to keep the keyboard input.

I'm a bit lost here as I'm not able to repro the issue in my sample app and I'm not able to fix my main app. I would really appreciated if you could adapt my sample in a way that it's working.

Thank you,
Stefan
eo_support
Posted: Saturday, January 25, 2014 10:41:48 AM
Rank: Administration
Groups: Administration

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

The problem is related to the page that you are loading in your sample app. If you load the page in Google Chrome browser, then click "Ouvrir une fenêtre popup" link at the bottom, the first time it opens the popup, but if you click it again, you will see the popup does not get activated. This corresponds to our "Activate" event. In the test app, if we click the link again, the popup WebView does not get "Activate" event. So the behavior of our WebView is consistent with Google Chrome's behavior (as it should be). If you try to load a regular page, both Google Chrome and our WebView will "Activate" the popup page.

The reason that the new popup does not get activated has to do with JavaScript code in gtmp.js (Google Tag Manager). It appears that the code in gtm.js overwrote your link's href code (and possibly hook up other events) thus changed the behavior of your link element. As a result, the browser engine does not reach the point of "activating" the popup window when the link is clicked, which is why the Activate event is not even fired for the WebView in the popup window. In another word, while you have been trying to find out what's wrong with your event handling code, the real problem is in fact that your event handling code is not even called.

In the future if you have similar problem, try to observe the behavior of Google Chrome browser. We can not derivative from the standard behavior. That will help you to determine whether the problem is in your page, or is in your code.

Hope this helps.

Thanks!
Stefan Koell
Posted: Saturday, January 25, 2014 12:47:18 PM
Rank: Advanced Member
Groups: Member

Joined: 12/23/2013
Posts: 114
My apologies. My efforts in implementing as much as possible from the docs made me forget to actually test it in chrome. You're right, the behavior is the same and as expected.

Anyway, I appreciate your support!
eo_support
Posted: Saturday, January 25, 2014 1:11:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,225
You are very welcome. Please feel free to let us know if there is anything else.

Thanks!
santosh
Posted: Tuesday, September 26, 2017 7:47:06 AM
Rank: Newbie
Groups: Member

Joined: 7/4/2017
Posts: 3
Hi,

We are using EOWebbrowser and to go to previous webpage, we have configured new shortcut as shown below.

- new Shortcut(CommandIds.Back, KeyCode.Left, false, true, false

But by pressing Alt+LeftArrow together it is not working. Press Alt button and leave and then pressing Left Arrow is working.

General chrome behaviour to take to previous page is Alt+LeftArrow together to be pressed.

Control Used : EO.Wpf.WebControl
eo_support
Posted: Saturday, September 30, 2017 5:53:25 PM
Rank: Administration
Groups: Administration

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

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

Thanks!
santosh
Posted: Wednesday, October 25, 2017 9:33:30 AM
Rank: Newbie
Groups: Member

Joined: 7/4/2017
Posts: 3
We are using EOWebbrowser.
We are facing issue that every time we load html and change url new sub process is created.
We have given name as "view.browserprocess.exe" through InitWorkerProcessExecutable.
is there any way to close older process or reuse existing process.
eo_support
Posted: Wednesday, October 25, 2017 10:18:41 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,225
santosh wrote:
We are using EOWebbrowser.
We are facing issue that every time we load html and change url new sub process is created.
We have given name as "view.browserprocess.exe" through InitWorkerProcessExecutable.
is there any way to close older process or reuse existing process.


Please repost your question in a new thread instead of just following up a completely unrelated thread. Forum posts are grouped in topics so that each thread is about one topic only. When you post your question in a completely unrelated thread, not only it makes it more difficult for other users to read and search by topics, but also sends out reply notifications to other users who have posted in the same thread notifying them a "reply" that has nothing to do with their previous discussion.


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.