From 27321e9c44a1afbddaa7693a56d93434d6f34558 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 12 Sep 2019 20:30:54 +0200 Subject: [PATCH] PaintBrush: Only send left and right mouse button events to tools Tools don't know what to do with the middle mouse button anyway, so it's better if we just don't pass it along. Fixes #546. --- Applications/PaintBrush/PaintableWidget.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Applications/PaintBrush/PaintableWidget.cpp b/Applications/PaintBrush/PaintableWidget.cpp index 613167beb2..1c1b6452d5 100644 --- a/Applications/PaintBrush/PaintableWidget.cpp +++ b/Applications/PaintBrush/PaintableWidget.cpp @@ -1,7 +1,7 @@ #include "PaintableWidget.h" #include "Tool.h" -#include #include +#include static PaintableWidget* s_the; @@ -57,20 +57,27 @@ Color PaintableWidget::color_for(const GMouseEvent& event) void PaintableWidget::mousedown_event(GMouseEvent& event) { - if (m_tool) - m_tool->on_mousedown(event); + if (event.button() == GMouseButton::Left || event.button() == GMouseButton::Right) { + if (m_tool) + m_tool->on_mousedown(event); + } + GWidget::mousedown_event(event); } void PaintableWidget::mouseup_event(GMouseEvent& event) { - if (m_tool) - m_tool->on_mouseup(event); + if (event.button() == GMouseButton::Left || event.button() == GMouseButton::Right) { + if (m_tool) + m_tool->on_mouseup(event); + } + GWidget::mouseup_event(event); } void PaintableWidget::mousemove_event(GMouseEvent& event) { if (m_tool) m_tool->on_mousemove(event); + GWidget::mousemove_event(event); } void PaintableWidget::set_primary_color(Color color)