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.
This commit is contained in:
Andreas Kling 2019-09-12 20:30:54 +02:00
parent d86fb8033e
commit 27321e9c44

View file

@ -1,7 +1,7 @@
#include "PaintableWidget.h"
#include "Tool.h"
#include <LibGUI/GPainter.h>
#include <LibDraw/GraphicsBitmap.h>
#include <LibGUI/GPainter.h>
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)