Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable mouse middle and right buttons for ImGui #1500

Merged
merged 2 commits into from
Sep 17, 2020
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* Fixed OSG transparent object sorting: [#1414](https://github.com/dartsim/dart/pull/1414)
* Added modifier key support to ImGuiHandler: [#1436](https://github.com/dartsim/dart/pull/1436)
* Fixed mixed intrinsic and extrinsic camera parameters in OpenGL projection matrix: [#1485](https://github.com/dartsim/dart/pull/1485)
* Enabled mouse middle and right buttons in ImGuiHandler: [#1500](https://github.com/dartsim/dart/pull/1500)

* Parser

Expand Down
28 changes: 27 additions & 1 deletion dart/gui/osg/ImGuiHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,29 @@ bool ImGuiHandler::handle(
{
io.MousePos
= ImVec2(eventAdapter.getX(), io.DisplaySize.y - eventAdapter.getY());
mMousePressed[0] = true;

if (eventAdapter.getButtonMask()
== osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
{
mMousePressed[0] = true;
}
else if (
eventAdapter.getButtonMask()
== osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
{
mMousePressed[1] = true;
}
else if (
eventAdapter.getButtonMask()
== osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON)
{
mMousePressed[2] = true;
}
else
{
// Shouldn't be reached to here. Mark left button by default.
mMousePressed[0] = true;
}

return wantCapureMouse;
}
Expand All @@ -363,7 +385,11 @@ bool ImGuiHandler::handle(
}
case osgGA::GUIEventAdapter::RELEASE:
{
// When a mouse button is released no button mask is set. So we mark all
// the buttons are released.
mMousePressed[0] = false;
mMousePressed[1] = false;
mMousePressed[2] = false;

return wantCapureMouse;
}
Expand Down