Skip to content

Commit

Permalink
IGL: Add input support for middle mouse button on Mac
Browse files Browse the repository at this point in the history
Summary: This diff adds support for middle mouse button events on Mac.

Reviewed By: corporateshark

Differential Revision: D49881119

fbshipit-source-id: ccbd7e8f7d5c067f448e5572f4d75c0202e0fbcb
  • Loading branch information
Eric Griffith authored and facebook-github-bot committed Oct 5, 2023
1 parent e9235ac commit 434f0ed
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions shell/mac/ViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ - (void)rightMouseDown:(NSEvent*)event {
igl::shell::MouseButtonEvent(igl::shell::MouseButton::Right, true, curPoint.x, curPoint.y));
}

- (void)otherMouseDown:(NSEvent*)event {
NSPoint curPoint = [self locationForEvent:event];
shellPlatform_->getInputDispatcher().queueEvent(
igl::shell::MouseButtonEvent(igl::shell::MouseButton::Middle, true, curPoint.x, curPoint.y));
}

- (void)mouseUp:(NSEvent*)event {
NSPoint curPoint = [self locationForEvent:event];
shellPlatform_->getInputDispatcher().queueEvent(
Expand All @@ -481,6 +487,12 @@ - (void)rightMouseUp:(NSEvent*)event {
igl::shell::MouseButtonEvent(igl::shell::MouseButton::Right, false, curPoint.x, curPoint.y));
}

- (void)otherMouseUp:(NSEvent*)event {
NSPoint curPoint = [self locationForEvent:event];
shellPlatform_->getInputDispatcher().queueEvent(
igl::shell::MouseButtonEvent(igl::shell::MouseButton::Middle, false, curPoint.x, curPoint.y));
}

- (void)mouseMoved:(NSEvent*)event {
NSPoint curPoint = [self locationForEvent:event];
shellPlatform_->getInputDispatcher().queueEvent(
Expand All @@ -499,6 +511,12 @@ - (void)rightMouseDragged:(NSEvent*)event {
igl::shell::MouseMotionEvent(curPoint.x, curPoint.y, event.deltaX, event.deltaY));
}

- (void)otherMouseDragged:(NSEvent*)event {
NSPoint curPoint = [self locationForEvent:event];
shellPlatform_->getInputDispatcher().queueEvent(
igl::shell::MouseMotionEvent(curPoint.x, curPoint.y, event.deltaX, event.deltaY));
}

- (void)scrollWheel:(NSEvent*)event {
shellPlatform_->getInputDispatcher().queueEvent(igl::shell::MouseWheelEvent(
event.scrollingDeltaX * kMouseSpeed_, event.scrollingDeltaY * kMouseSpeed_));
Expand Down

0 comments on commit 434f0ed

Please sign in to comment.