Skip to content

Commit

Permalink
Merge pull request TrenchBroom#4218 from TrenchBroom/4214
Browse files Browse the repository at this point in the history
4214: Only cancel mouse drags if window deactivates
  • Loading branch information
kduske authored Feb 28, 2023
2 parents 80d3498 + fa28809 commit a44eefb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
11 changes: 10 additions & 1 deletion common/src/View/MapViewBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,16 @@ void MapViewBase::hideAllEntityLinks()
setPref(Preferences::FaceRenderMode, Preferences::entityLinkModeNone());
}

bool MapViewBase::event(QEvent* event)
{
if (event->type() == QEvent::WindowDeactivate)
{
cancelMouseDrag();
}

return RenderView::event(event);
}

void MapViewBase::focusInEvent(QFocusEvent* event)
{
updateActionStates(); // enable/disable QShortcut's to reflect whether we have focus
Expand All @@ -914,7 +924,6 @@ void MapViewBase::focusInEvent(QFocusEvent* event)

void MapViewBase::focusOutEvent(QFocusEvent* event)
{
cancelMouseDrag();
clearModifierKeys();
update();
RenderView::focusOutEvent(event);
Expand Down
2 changes: 1 addition & 1 deletion common/src/View/MapViewBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class MapViewBase : public RenderView,
void showDirectlySelectedEntityLinks();
void hideAllEntityLinks();

protected:
bool event(QEvent* event) override;
void focusInEvent(QFocusEvent* event) override;
void focusOutEvent(QFocusEvent* event) override;

Expand Down
10 changes: 7 additions & 3 deletions common/src/View/UVView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ void UVView::setSubDivisions(const vm::vec2i& subDivisions)
update();
}

void UVView::focusOutEvent(QFocusEvent* event)
bool UVView::event(QEvent* event)
{
ToolBoxConnector::cancelDrag();
RenderView::focusOutEvent(event);
if (event->type() == QEvent::WindowDeactivate)
{
cancelDrag();
}

return RenderView::event(event);
}

void UVView::createTools()
Expand Down
3 changes: 1 addition & 2 deletions common/src/View/UVView.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ class UVView : public RenderView, public ToolBoxConnector

void setSubDivisions(const vm::vec2i& subDivisions);

protected:
void focusOutEvent(QFocusEvent* event) override;
bool event(QEvent* event) override;

private:
void createTools();
Expand Down

0 comments on commit a44eefb

Please sign in to comment.