IWithPointerDownAndUp.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright (c) 2024 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 UnityEngine;
  15. namespace Vuplex.WebView {
  16. /// <summary>
  17. /// An interface implemented by a webview if it supports PointerDown()
  18. /// and PointerUp(), which can be used to implement functionality like
  19. /// drag interactions, double-clicks, and right-clicks.
  20. /// </summary>
  21. /// <remarks>
  22. /// For details on the limitations of drag interactions on iOS and UWP, please see
  23. /// https://support.vuplex.com/articles/hover-and-drag-limitations.
  24. /// </remarks>
  25. /// <example>
  26. /// <code>
  27. /// var webViewWithPointerDownAndUp = webViewPrefab.WebView as IWithPointerDownAndUp;
  28. /// if (webViewWithPointerDownAndUp != null) {
  29. /// // Double right click at (250px, 100px) in the web page.
  30. /// var normalizedPoint = webViewPrefab.WebView.PointToNormalized(250, 100);
  31. /// var pointerOptions = new PointerOptions {
  32. /// Button = MouseButton.Right,
  33. /// ClickCount = 2
  34. /// };
  35. /// webViewWithPointerDownAndUp.PointerDown(normalizedPoint, pointerOptions);
  36. /// webViewWithPointerDownAndUp.PointerUp(normalizedPoint, pointerOptions);
  37. /// }
  38. /// </code>
  39. /// </example>
  40. public interface IWithPointerDownAndUp {
  41. /// <summary>
  42. /// Dispatches a pointerdown / mousedown click event at the given normalized point.
  43. /// This can be used in conjunction with IWithMovablePointer.MovePointer() and
  44. /// PointerUp() to implement drag interactions.
  45. /// </summary>
  46. /// <seealso cref="IWebView.Click"/>
  47. void PointerDown(Vector2 normalizedPoint);
  48. /// <summary>
  49. /// Like PointerDown(Vector2), except it also accepts a
  50. /// PointerOptions parameter to modify the behavior
  51. /// (e.g. to trigger a right click or a double click).
  52. /// </summary>
  53. void PointerDown(Vector2 normalizedPoint, PointerOptions options);
  54. /// <summary>
  55. /// Dispatches a pointerup / mouseup click event at the given normalized point.
  56. /// This can be used in conjunction with PointerDown() and
  57. /// IWithMovablePointer.MovePointer() and to implement drag interactions.
  58. /// </summary>
  59. /// <seealso cref="IWebView.Click"/>
  60. void PointerUp(Vector2 normalizedPoint);
  61. /// <summary>
  62. /// Like PointerUp(Vector2), except it also accepts a
  63. /// PointerOptions parameter to modify the behavior
  64. /// (e.g. to trigger a right click or a double click).
  65. /// </summary>
  66. void PointerUp(Vector2 normalizedPoint, PointerOptions options);
  67. }
  68. }