clipboardEvents.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Gather the list of clipboard event types as constants.
  3. */
  4. export class ClipboardEventTypes {
  5. }
  6. /**
  7. * The clipboard event is fired when a copy command is active (pressed).
  8. */
  9. ClipboardEventTypes.COPY = 0x01; //
  10. /**
  11. * The clipboard event is fired when a cut command is active (pressed).
  12. */
  13. ClipboardEventTypes.CUT = 0x02;
  14. /**
  15. * The clipboard event is fired when a paste command is active (pressed).
  16. */
  17. ClipboardEventTypes.PASTE = 0x03;
  18. /**
  19. * This class is used to store clipboard related info for the onClipboardObservable event.
  20. */
  21. export class ClipboardInfo {
  22. /**
  23. *Creates an instance of ClipboardInfo.
  24. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  25. * @param event Defines the related dom event
  26. */
  27. constructor(
  28. /**
  29. * Defines the type of event (BABYLON.ClipboardEventTypes)
  30. */
  31. type,
  32. /**
  33. * Defines the related dom event
  34. */
  35. event) {
  36. this.type = type;
  37. this.event = event;
  38. }
  39. /**
  40. * Get the clipboard event's type from the keycode.
  41. * @param keyCode Defines the keyCode for the current keyboard event.
  42. * @returns {number}
  43. */
  44. static GetTypeFromCharacter(keyCode) {
  45. const charCode = keyCode;
  46. //TODO: add codes for extended ASCII
  47. switch (charCode) {
  48. case 67:
  49. return ClipboardEventTypes.COPY;
  50. case 86:
  51. return ClipboardEventTypes.PASTE;
  52. case 88:
  53. return ClipboardEventTypes.CUT;
  54. default:
  55. return -1;
  56. }
  57. }
  58. }
  59. //# sourceMappingURL=clipboardEvents.js.map