Skip to content

Commit

Permalink
Add force focus when mouse enters render window (#95)
Browse files Browse the repository at this point in the history
Signed-off-by: John Shepherd <john@openrobotics.org>
  • Loading branch information
John authored May 1, 2020
1 parent 536a08d commit 9f913a2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
1. Add ability to save worlds to SDFormat
* [BitBucket pull request 545](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-gazebo/pull-requests/545)

1. Add window focus upon mouse entering the render window
* [Github pull request 95](https://github.com/ignitionrobotics/ign-gazebo/pull/95)

### Ignition Gazebo 2.16.0 (2020-03-24)

1. Add support for computing model bounding box in physics system
Expand Down
3 changes: 3 additions & 0 deletions src/gui/plugins/scene3d/GzScene3D.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Rectangle {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
onEntered: {
GzScene3D.OnFocusWindow()
}
}

RenderWindow {
Expand Down
7 changes: 7 additions & 0 deletions src/gui/plugins/scene3d/Scene3D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,13 @@ void Scene3D::OnDropped(const QString &_drop, int _mouseX, int _mouseY)
req, cb);
}

/////////////////////////////////////////////////
void Scene3D::OnFocusWindow()
{
auto renderWindow = this->PluginItem()->findChild<RenderWindowItem *>();
renderWindow->forceActiveFocus();
}

/////////////////////////////////////////////////
void RenderWindowItem::SetXYZSnap(const math::Vector3d &_xyz)
{
Expand Down
4 changes: 4 additions & 0 deletions src/gui/plugins/scene3d/Scene3D.hh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
public slots: void OnDropped(const QString &_drop,
int _mouseX, int _mouseY);

/// \brief Callback when the mouse enters the render window to
/// focus the window for mouse/key events
public slots: void OnFocusWindow();

// Documentation inherited
protected: bool eventFilter(QObject *_obj, QEvent *_event) override;

Expand Down

0 comments on commit 9f913a2

Please sign in to comment.