Skip to content

Commit

Permalink
fix: properly bind clickCount from dom mouse events to java fireMouse…
Browse files Browse the repository at this point in the history
…Event
  • Loading branch information
tpoisseau committed Jul 23, 2024
1 parent 00a07e7 commit e1c5007
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/canvas_editor/events.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
'use strict';

/**
*
* @param {HTMLCanvasElement} canvasElement
* @param drawArea
* @param JavaEditorArea
*/
function addMouseListeners(canvasElement, drawArea, JavaEditorArea) {
let isMouseDown = false;

Expand All @@ -23,12 +29,12 @@ function addMouseListeners(canvasElement, drawArea, JavaEditorArea) {

canvasElement.addEventListener('mousedown', (ev) => {
isMouseDown = true;
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_PRESSED, ev);
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_PRESSED, ev, ev.detail);
});
// Listen on document to capture mouse release outside the canvas.
document.addEventListener('mouseup', (ev) => {
isMouseDown = false;
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_RELEASED, ev);
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_RELEASED, ev, ev.detail);
});
canvasElement.addEventListener('click', (ev) => {
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_CLICKED, ev, ev.detail);
Expand Down

0 comments on commit e1c5007

Please sign in to comment.