IWithPopups.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2022 Vuplex Inc. All rights reserved.
  2. //
  3. // Licensed under the Vuplex Commercial Software Library License, you may
  4. // not use this file except in compliance with the License. You may obtain
  5. // a copy of the License at
  6. //
  7. // https://vuplex.com/commercial-library-license
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. using System;
  15. namespace Vuplex.WebView {
  16. /// <summary>
  17. /// An interface implemented by a webview if it supports opening popups.
  18. /// For detailed examples, please see 3D WebView's PopupDemo and CanvasPopupDemo
  19. /// scenes.
  20. /// </summary>
  21. /// <example>
  22. /// <code>
  23. /// await webViewPrefab.WaitUntilInitialized;
  24. /// var webViewWithPopups = webViewPrefab.WebView as IWithPopups;
  25. /// if (webViewWithPopups != null) {
  26. /// webViewWithPopups.SetPopupMode(PopupMode.LoadInNewWebView);
  27. ///
  28. /// webViewWithPopups.PopupRequested += async (sender, eventArgs) => {
  29. /// Debug.Log("Popup opened with URL: " + eventArgs.Url);
  30. /// // Create and display a new WebViewPrefab for the popup.
  31. /// var popupPrefab = WebViewPrefab.Instantiate(eventArgs.WebView);
  32. /// popupPrefab.transform.parent = transform;
  33. /// popupPrefab.transform.localPosition = Vector3.zero;
  34. /// popupPrefab.transform.localEulerAngles = new Vector3(0, 180, 0);
  35. /// await popupPrefab.WaitUntilInitialized();
  36. /// popupPrefab.WebView.CloseRequested += (popupWebView, closeEventArgs) => {
  37. /// Debug.Log("Closing the popup");
  38. /// popupPrefab.Destroy();
  39. /// };
  40. /// };
  41. /// }
  42. /// </code>
  43. /// </example>
  44. public interface IWithPopups {
  45. /// <summary>
  46. /// Sets how the webview handles popups.
  47. /// </summary>
  48. void SetPopupMode(PopupMode popupMode);
  49. /// <summary>
  50. /// Indicates that the webview requested a popup.
  51. /// </summary>
  52. event EventHandler<PopupRequestedEventArgs> PopupRequested;
  53. }
  54. }