diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp index 002705b0c9..4abe9b882f 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp @@ -160,10 +160,41 @@ void GlyphMapWidget::mousedown_event(MouseEvent& event) m_selection.set_size(1); m_selection.set_start(glyph); } + m_in_drag_select = true; set_active_glyph(glyph, ShouldResetSelection::No); } } +void GlyphMapWidget::mouseup_event(GUI::MouseEvent& event) +{ + Frame::mouseup_event(event); + + if (!m_in_drag_select) + return; + + if (auto maybe_glyph = glyph_at_position(event.position()); maybe_glyph.has_value()) { + auto glyph = maybe_glyph.value(); + m_selection.extend_to(glyph); + m_in_drag_select = false; + set_active_glyph(glyph, ShouldResetSelection::No); + } +} + +void GlyphMapWidget::mousemove_event(GUI::MouseEvent& event) +{ + Frame::mousemove_event(event); + + if (!m_in_drag_select) + return; + + if (auto maybe_glyph = glyph_at_position(event.position()); maybe_glyph.has_value()) { + auto glyph = maybe_glyph.value(); + m_selection.extend_to(glyph); + scroll_to_glyph(glyph); + update(); + } +} + void GlyphMapWidget::doubleclick_event(MouseEvent& event) { Widget::doubleclick_event(event); diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.h b/Userland/Libraries/LibGUI/GlyphMapWidget.h index a634e5f409..2dad29a345 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.h +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.h @@ -69,6 +69,8 @@ private: GlyphMapWidget(); virtual void paint_event(PaintEvent&) override; virtual void mousedown_event(MouseEvent&) override; + virtual void mouseup_event(GUI::MouseEvent&) override; + virtual void mousemove_event(GUI::MouseEvent&) override; virtual void doubleclick_event(MouseEvent&) override; virtual void keydown_event(KeyEvent&) override; virtual void resize_event(ResizeEvent&) override; @@ -87,6 +89,7 @@ private: Selection m_selection; int m_active_glyph { 0 }; int m_visible_glyphs { 0 }; + bool m_in_drag_select { false }; }; }