(event)
| 699 | return this.layers.drawing.canvas |
| 700 | } |
| 701 | keyHandler(event) { |
| 702 | // handles keybinds like ctrl+z, ctrl+y |
| 703 | if (!this.popup.classList.contains("active")) { |
| 704 | document.removeEventListener("keydown", this.keyHandlerBound) |
| 705 | document.removeEventListener("keyup", this.keyHandlerBound) |
| 706 | return // this catches if something else closes the window but doesnt properly unbind the key handler |
| 707 | } |
| 708 | |
| 709 | // keybindings |
| 710 | if (event.type == "keydown") { |
| 711 | if ((event.key == "z" || event.key == "Z") && event.ctrlKey) { |
| 712 | if (!event.shiftKey) { |
| 713 | this.history.undo() |
| 714 | } else { |
| 715 | this.history.redo() |
| 716 | } |
| 717 | event.stopPropagation() |
| 718 | event.preventDefault() |
| 719 | } |
| 720 | else if (event.key == "y" && event.ctrlKey) { |
| 721 | this.history.redo() |
| 722 | event.stopPropagation() |
| 723 | event.preventDefault() |
| 724 | } |
| 725 | else if (event.key === "Escape") { |
| 726 | this.hide() |
| 727 | event.stopPropagation() |
| 728 | event.preventDefault() |
| 729 | } else { |
| 730 | let toolIndex = IMAGE_EDITOR_TOOLS.findIndex(t => t.hotkey == event.key) |
| 731 | if (toolIndex != -1) { |
| 732 | this.selectOption("tool", toolIndex) |
| 733 | event.stopPropagation() |
| 734 | event.preventDefault() |
| 735 | } |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | // dropper ctrl holding handler stuff |
| 740 | var dropper_active = this.temp_previous_tool != null |
| 741 | if (dropper_active && !event.ctrlKey) { |
| 742 | this.selectOption( |
| 743 | "tool", |
| 744 | IMAGE_EDITOR_TOOLS.findIndex((t) => t.id == this.temp_previous_tool) |
| 745 | ) |
| 746 | this.temp_previous_tool = null |
| 747 | } else if (!dropper_active && event.ctrlKey) { |
| 748 | this.temp_previous_tool = this.getOptionValue("tool") |
| 749 | this.selectOption( |
| 750 | "tool", |
| 751 | IMAGE_EDITOR_TOOLS.findIndex((t) => t.id == "colorpicker") |
| 752 | ) |
| 753 | } |
| 754 | } |
| 755 | mouseHandler(event) { |
| 756 | var bbox = this.layers.overlay.canvas.getBoundingClientRect() |
| 757 | var x = (event.clientX || 0) - bbox.left |
nothing calls this directly
no test coverage detected