Skip to content

Commit

Permalink
Enable mouse middle and right buttons for ImGui
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeongseok Lee committed Sep 16, 2020
1 parent c6391f7 commit c3bd4f2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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

0 comments on commit c3bd4f2

Please sign in to comment.