IWithKeyDownAndUp.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 separate
  17. /// `KeyDown()` and `KeyUp()` methods.
  18. /// </summary>
  19. /// <example>
  20. /// <code>
  21. /// // Dispatch ctrl + shift + right arrow
  22. /// await webViewPrefab.WaitUntilInitialized();
  23. /// var webViewWithKeyDownAndUp = webViewPrefab.WebView as IWithKeyDownAndUp;
  24. /// if (webViewWithKeyDownAndUp != null) {
  25. /// webViewWithKeyDownAndUp.KeyDown("ArrowRight", KeyModifier.Control | KeyModifier.Shift);
  26. /// webViewWithKeyDownAndUp.KeyUp("ArrowRight", KeyModifier.Control | KeyModifier.Shift);
  27. /// }
  28. /// </code>
  29. /// </example>
  30. public interface IWithKeyDownAndUp {
  31. /// <summary>
  32. /// Dispatches a key down event to the webview.
  33. /// </summary>
  34. /// <param name="key">
  35. /// A key can either be a single character representing
  36. /// a unicode character (e.g. "A", "b", "?") or a [JavaScript Key value](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
  37. /// (e.g. "ArrowUp", "Enter").
  38. /// </param>
  39. /// <param name="modifiers">
  40. /// Modifier flags that can be used to trigger keyboard shortcuts.
  41. /// </param>
  42. void KeyDown(string key, KeyModifier modifiers);
  43. /// <summary>
  44. /// Dispatches a key up event to the webview.
  45. /// </summary>
  46. /// <param name="key">
  47. /// A key can either be a single character representing
  48. /// a unicode character (e.g. "A", "b", "?") or a [JavaScript Key value](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
  49. /// (e.g. "ArrowUp", "Enter").
  50. /// </param>
  51. /// <param name="modifiers">
  52. /// Modifier flags that can be used to trigger keyboard shortcuts.
  53. /// </param>
  54. void KeyUp(string key, KeyModifier modifiers);
  55. }
  56. }