Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ mouse.on('move', function(x, y) {

The program will not terminate as long as a mouse listener is active. To allow the program to exit, either call `mouse.unref` (works as `unref`/`ref` on a TCP server) or `mouse.destroy()`.

The events emitted are: `move`, `left-down`, `left-up`, `left-drag`, `right-up`, `right-down` and `right-drag`. For each event the screen coordinates are passed to the handler function.
The events emitted are: `middle-up`, `middle-down`, `move`, `left-down`, `left-up`, `left-drag`, `right-up`, `right-down` and `right-drag`. For each event the screen coordinates are passed to the handler function.
6 changes: 6 additions & 0 deletions source/mouse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ const char* LEFT_DOWN = "left-down";
const char* LEFT_UP = "left-up";
const char* RIGHT_DOWN = "right-down";
const char* RIGHT_UP = "right-up";
const char* MIDDLE_DOWN = "middle-down";
const char* MIDDLE_UP = "middle-up";
const char* MOVE = "move";

bool IsMouseEvent(WPARAM type) {
return type == WM_LBUTTONDOWN ||
type == WM_LBUTTONUP ||
type == WM_RBUTTONDOWN ||
type == WM_RBUTTONUP ||
type == WM_MBUTTONDOWN ||
type == WM_MBUTTONUP ||
type == WM_MOUSEMOVE;
}

Expand Down Expand Up @@ -131,6 +135,8 @@ void Mouse::HandleSend() {
if (e.type == WM_LBUTTONUP) name = LEFT_UP;
if (e.type == WM_RBUTTONDOWN) name = RIGHT_DOWN;
if (e.type == WM_RBUTTONUP) name = RIGHT_UP;
if (e.type == WM_MBUTTONDOWN) name = MIDDLE_DOWN;
if (e.type == WM_MBUTTONUP) name = MIDDLE_UP;
if (e.type == WM_MOUSEMOVE) name = MOVE;

Local<Value> argv[] = {
Expand Down