IWithTouch.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. namespace Vuplex.WebView {
  15. /// <summary>
  16. /// An interface implemented by a webview if it supports dispatching touch events.
  17. /// </summary>
  18. public interface IWithTouch {
  19. /// <summary>
  20. /// Dispatches a touch event (i.e. touchstart, touchend, touchmove, touchcancel) in
  21. /// the webview. This can be used, for example, to implement multitouch interactions.
  22. /// </summary>
  23. /// <example>
  24. /// <code>
  25. /// var webViewWithTouch = webViewPrefab.WebView as IWithTouch;
  26. /// if (webViewWithTouch == null) {
  27. /// Debug.Log("This 3D WebView plugin doesn't yet support IWithTouch: " + webViewPrefab.WebView.PluginType);
  28. /// return;
  29. /// }
  30. /// // Start and end a first touch at (250px, 100px) in the web page.
  31. /// var normalizedPoint1 = webViewPrefab.WebView.PointToNormalized(250, 100);
  32. /// webViewWithTouch.SendTouchEvent(new TouchEvent {
  33. /// TouchID = 1,
  34. /// Point = normalizedPoint1,
  35. /// Type = TouchEventType.Start
  36. /// });
  37. ///
  38. /// webViewWithTouch.SendTouchEvent(new TouchEvent {
  39. /// TouchID = 1,
  40. /// Point = normalizedPoint1,
  41. /// Type = TouchEventType.End
  42. /// });
  43. ///
  44. /// // Start a second touch at (400px, 100px), move it to (410px, 100), and release it.
  45. /// var normalizedPoint2 = webViewPrefab.WebView.PointToNormalized(400, 100);
  46. /// webViewWithTouch.SendTouchEvent(new TouchEvent {
  47. /// TouchID = 2,
  48. /// Point = normalizedPoint2,
  49. /// Type = TouchEventType.Start
  50. /// });
  51. ///
  52. /// var normalizedPoint3 = webViewPrefab.WebView.PointToNormalized(410, 100);
  53. /// webViewWithTouch.SendTouchEvent(new TouchEvent {
  54. /// TouchID = 2,
  55. /// Point = normalizedPoint3,
  56. /// Type = TouchEventType.Move
  57. /// });
  58. ///
  59. /// webViewWithTouch.SendTouchEvent(new TouchEvent {
  60. /// TouchID = 2,
  61. /// Point = normalizedPoint3,
  62. /// Type = TouchEventType.End
  63. /// });
  64. /// </code>
  65. /// </example>
  66. void SendTouchEvent(TouchEvent touchEvent);
  67. }
  68. }