bkeiren / AwesomiumUnity

Third-party Awesomium wrapper for Unity3D, wrapping Awesomium's C++ API with a custom C# API and accompanying Unity MonoBehaviour components.
108 stars 74 forks source link

Opening new tabs (using ShowCreatedWebView event) #8

Closed TheMajorO closed 8 years ago

TheMajorO commented 8 years ago

Hey! As the title says, I am trying to implement new-tab behavior in my application. Until now any new link opens in the same webview. I would like to handle new tabs generated from either: _target=”blank”, _target=”new”, window.open, or by manually triggering new tab behavior just like right clicking and opening a new tab in Chrome or Firefox (perhaps by manually calling TriggerShowCreatedWebView in AwesomiumUnityWebView.cs or maybe executing JS function window.open).

Am I on the right track? Is this the right way to do it? (Awesomium-wise not Unity-wise) Any further details and directions are highly appreciable.

TheMajorO commented 8 years ago

Everything is working SO smoothly :) Just beautiful! Even using middle mouse click opens a new tab :D So I might inject middle mouse when i wanna manually open a new tab using other input (e.g. right click menu that calls a method which in turn injects middle mouse in order to open in a new tab)

TheMajorO commented 8 years ago

Oops! middle mouse click opens new tabs only for links that actually open in new tab when you left-click it (i.e. links with target=”_blank” or target=”_new”) I still need a way to manually open highlighted links in a new tab... Perhaps call some JS function that returns highlighted link and then somehow trigger opening a new web view?

TheMajorO commented 8 years ago

Solved :) https://stackoverflow.com/questions/31772500/function-to-get-href-of-link-at-mouse-location-on-hover-something-similar-to-co/31784274#31784274

Also, there is a built-in callback in the engine which serves the same purpose that I might be adding to the wrapper: http://www.awesomium.com/docs/1_7_2/cpp_api/class_awesomium_1_1_web_view_listener_1_1_view.html#**ad6ce4c9b7c5d6f1751f6b009d1d70b2b

Edit: In fact OnChangeTargetURL is already in ViewListener.h but not in ViewListener.cpp.