Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

[WIP] Handle missing mouse events #2513

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions browser/src/Input/Mouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,20 @@ export class Mouse extends EventEmitter {
this._editorElement.addEventListener("mousedown", (evt: MouseEvent) => {
const { line, column } = this._convertEventToPosition(evt)

this.emit("mouse", `<LeftMouse><${line},${column}>`)
this._isDragging = true
switch (evt.which) {
case 1:
this.emit("mouse", `<LeftMouse><${line},${column}>`)
this._isDragging = true
break
case 2:
this.emit("mouse", `<MiddleMouse>`)
break
case 3:
this.emit("mouse", `<RightMouse><${line},${column}>`)
break
default:
break
}
})

this._editorElement.addEventListener("mousemove", (evt: MouseEvent) => {
Expand All @@ -29,10 +41,16 @@ export class Mouse extends EventEmitter {
})

this._editorElement.addEventListener("mouseup", (evt: MouseEvent) => {
const { line, column } = this._convertEventToPosition(evt)

this.emit("mouse", `<LeftRelease><${line},${column}>`)
this._isDragging = false
switch (evt.which) {
case 1:
const { line, column } = this._convertEventToPosition(evt)

this.emit("mouse", `<LeftRelease><${line},${column}>`)
this._isDragging = false
break
default:
break
}
})

// The internet told me 'mousewheel' is deprecated and use this.
Expand Down