diff --git a/src/app/commands/cmd_new_brush.cpp b/src/app/commands/cmd_new_brush.cpp index 81d1ee53b..22cd0a45c 100644 --- a/src/app/commands/cmd_new_brush.cpp +++ b/src/app/commands/cmd_new_brush.cpp @@ -42,6 +42,7 @@ protected: // SelectBoxDelegate impl void onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons buttons) override; + void onQuickboxCancel() override; private: void createBrush(const Mask* mask); @@ -116,6 +117,11 @@ void NewBrushCommand::onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons butt current_editor->backToPreviousState(); } +void NewBrushCommand::onQuickboxCancel() +{ + current_editor->backToPreviousState(); +} + void NewBrushCommand::createBrush(const Mask* mask) { doc::ImageRef image(new_image_from_mask( diff --git a/src/app/ui/editor/select_box_state.cpp b/src/app/ui/editor/select_box_state.cpp index f320a0aed..1f232e524 100644 --- a/src/app/ui/editor/select_box_state.cpp +++ b/src/app/ui/editor/select_box_state.cpp @@ -80,6 +80,7 @@ bool SelectBoxState::onMouseDown(Editor* editor, MouseMessage* msg) if (hasFlag(QUICKBOX) && m_movingRuler == -1) { m_selectingBox = true; + m_selectingButtons = msg->buttons(); m_startingPos = editor->screenToEditor(msg->position()); setBoxBounds(gfx::Rect(m_startingPos, gfx::Size(1, 1))); } @@ -96,8 +97,13 @@ bool SelectBoxState::onMouseUp(Editor* editor, MouseMessage* msg) if (m_selectingBox) { m_selectingBox = false; - if (m_delegate) - m_delegate->onQuickboxEnd(getBoxBounds(), msg->buttons()); + + if (m_delegate) { + if (m_selectingButtons == msg->buttons()) + m_delegate->onQuickboxEnd(getBoxBounds(), msg->buttons()); + else + m_delegate->onQuickboxCancel(); + } } return StandbyState::onMouseUp(editor, msg); diff --git a/src/app/ui/editor/select_box_state.h b/src/app/ui/editor/select_box_state.h index 8f04df8fb..e210325d5 100644 --- a/src/app/ui/editor/select_box_state.h +++ b/src/app/ui/editor/select_box_state.h @@ -29,6 +29,7 @@ namespace app { // Called only in QUICKBOX mode, when the user released the mouse // button. virtual void onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons buttons) { } + virtual void onQuickboxCancel() { } }; class SelectBoxState : public StandbyState @@ -77,6 +78,7 @@ namespace app { Rulers m_rulers; int m_movingRuler; bool m_selectingBox; + ui::MouseButtons m_selectingButtons; gfx::Point m_startingPos; Flags m_flags; };