Welcome Guest Search | Active Topics | Sign In | Register

EO.WebBrowser open link in other WebView Options
Cristiano Conte
Posted: Monday, October 13, 2014 4:29:57 PM
Rank: Member
Groups: Member

Joined: 9/25/2014
Posts: 19
Hi,

I'd like open some links the site in others WebView, to work equal the Shortcut "Ctrl+Left Click".

Thanks.
eo_support
Posted: Tuesday, October 14, 2014 10:30:06 AM
Rank: Administration
Groups: Administration

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

The WebView already does that. What you need to do is to handle NewWindow event properly. See here for more details:

http://www.essentialobjects.com/doc/6/advanced/new_window.aspx

You can find sample code in our TabbedBrowser sample project on how to handle this event.

Thanks!
Cristiano Conte
Posted: Tuesday, October 14, 2014 12:42:04 PM
Rank: Member
Groups: Member

Joined: 9/25/2014
Posts: 19
Hi,

Is not what I need. My idea is create one item in ContextMenu "Open link in new tab" with shorcut "Ctrl + Left Click", that will open any links on the website, the choice is the user.

Thanks.

eo_support wrote:
Hi,

The WebView already does that. What you need to do is to handle NewWindow event properly. See here for more details:

http://www.essentialobjects.com/doc/6/advanced/new_window.aspx

You can find sample code in our TabbedBrowser sample project on how to handle this event.

Thanks!
eo_support
Posted: Tuesday, October 14, 2014 12:55:43 PM
Rank: Administration
Groups: Administration

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

In that case you would need to:

1. Customize the context menu with the specified short key. See here for more information on how to customize the context menu:

http://www.essentialobjects.com/doc/6/customize/context_menu.aspx

As you can see, you will customize the context menu by handling BeforeContextMenu event.

2. Also in your BeforeContextMenu event handler, you will need to check the event argument's MenuInfo property to find out whether this is a context menu for a link, and if it is a link, what is the link Url. You can get this from these two properties:

http://www.essentialobjects.com/doc/6/eo.webbrowser.contextmenusourceflags.aspx
http://www.essentialobjects.com/doc/6/eo.webbrowser.contextmenuinfo.linkurl.aspx

3. Handle the WebView's Command event:

http://www.essentialobjects.com/doc/6/eo.webbrowser.webview.command.aspx

This event is triggered when user clicks a menu item in the context menu (each menu item will be associated to a different command id). Inside the event handler you can do whatever you want with the new Url. For example, if you want to disable the link, you can do nothing. If you want to load into the current WebView, you can call LoadUrl on the current WebView. If you want to load it into a new WebView, you can create a new WebView (along with the wrapper class, for example, if you uses Windows Forms then you need to create EO.WebBrowser.WinForm.WebControl) and load the Url you get in step 2 into the new WebView.

Hope this helps.

Thanks!



Cristiano Conte
Posted: Tuesday, October 14, 2014 1:15:04 PM
Rank: Member
Groups: Member

Joined: 9/25/2014
Posts: 19
Hi,

Thanks for fast reply. The steps 1,2 and event WebView.Command is perfect. My problem is how does get the clicked value URL for open in other WebView?

Code: C#
void WebView_Command(object sender, EO.WebBrowser.CommandEventArgs e)
{
	if (e.CommandId.Equals(OpenNewTab))
	{
		//Get the URL and open in the new WebView		
	}
}


Thanks!

eo_support wrote:
Hi,

In that case you would need to:

1. Customize the context menu with the specified short key. See here for more information on how to customize the context menu:

http://www.essentialobjects.com/doc/6/customize/context_menu.aspx

As you can see, you will customize the context menu by handling BeforeContextMenu event.

2. Also in your BeforeContextMenu event handler, you will need to check the event argument's MenuInfo property to find out whether this is a context menu for a link, and if it is a link, what is the link Url. You can get this from these two properties:

http://www.essentialobjects.com/doc/6/eo.webbrowser.contextmenusourceflags.aspx
http://www.essentialobjects.com/doc/6/eo.webbrowser.contextmenuinfo.linkurl.aspx

3. Handle the WebView's Command event:

http://www.essentialobjects.com/doc/6/eo.webbrowser.webview.command.aspx

This event is triggered when user clicks a menu item in the context menu (each menu item will be associated to a different command id). Inside the event handler you can do whatever you want with the new Url. For example, if you want to disable the link, you can do nothing. If you want to load into the current WebView, you can call LoadUrl on the current WebView. If you want to load it into a new WebView, you can create a new WebView (along with the wrapper class, for example, if you uses Windows Forms then you need to create EO.WebBrowser.WinForm.WebControl) and load the Url you get in step 2 into the new WebView.

Hope this helps.

Thanks!



eo_support
Posted: Tuesday, October 14, 2014 1:36:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
You can't get that in step 3. You would get it in step 2 and keep it somewhere later for step 3. :)
Cristiano Conte
Posted: Tuesday, October 14, 2014 1:51:21 PM
Rank: Member
Groups: Member

Joined: 9/25/2014
Posts: 19
Hi

Oh, sorry, great worked.

;)

Thanks very much!!!!

eo_support wrote:
You can't get that in step 3. You would get it in step 2 and keep it somewhere later for step 3. :)
eo_support
Posted: Tuesday, October 14, 2014 2:00:04 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
You are very welcome. Please feel free to let us know if you have any more questions.

Thanks!


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.