Skip to content

Commit

Permalink
fix: double click event handling (#232)
Browse files Browse the repository at this point in the history
add comment to not forget `event.detail` on `pointerup` / `pointerdown` do not have clickCount information

Refs: Actelion/openchemlib#114
Closes: #225
  • Loading branch information
tpoisseau authored Oct 14, 2024
1 parent 5eb0ed8 commit 8cb438b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/canvas_editor/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ function addPointerListeners(canvasElement, drawArea, JavaEditorArea) {
canvasElement.addEventListener('pointerdown', (ev) => {
if (pointerDownId === -1) {
pointerDownId = ev.pointerId;
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_PRESSED, ev, ev.detail);
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_PRESSED, ev);
}
});

function handlePointerUp(ev) {
if (pointerDownId === ev.pointerId) {
pointerDownId = -1;
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_RELEASED, ev, ev.detail);
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_RELEASED, ev);
}
}
// Listen on document to capture mouse release outside the canvas.
Expand All @@ -47,9 +47,11 @@ function addPointerListeners(canvasElement, drawArea, JavaEditorArea) {
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_CLICKED, ev, ev.detail);
});
canvasElement.addEventListener('pointerenter', (ev) => {
// event.detail on pointerenter doesn't include the click count
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_ENTERED, ev);
});
canvasElement.addEventListener('pointerleave', (ev) => {
// event.detail on pointerenter doesn't include the click count
fireMouseEvent(JavaEditorArea.MOUSE_EVENT_EXITED, ev);
});
canvasElement.addEventListener('pointermove', (ev) => {
Expand Down

0 comments on commit 8cb438b

Please sign in to comment.