diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2022-03-19 13:29:55 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-20 20:00:25 +0100 |
commit | b8cc18896f3fe912b46051ae99c0981f291f96db (patch) | |
tree | 5584780c785e00030e51bf0107bc9fa192641170 /Userland/Libraries | |
parent | 42284a1550bcf2f7662616e3b5235e88928f2af3 (diff) | |
download | serenity-b8cc18896f3fe912b46051ae99c0981f291f96db.zip |
LibGUI+FontEditor: Add context menu for editor actions
GlyphMapWidget now reports context menu requests when secondary
clicking the map. This also adds a new Select All action and updates
the Copy Character action to work on multi-glyph selections. Glyph
navigation actions have been moved to a separate Go menu, as is
common in other apps.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/GlyphMapWidget.cpp | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/GlyphMapWidget.h | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp index b529f7c7df..2ae04e1325 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp @@ -182,8 +182,17 @@ int GlyphMapWidget::glyph_at_position_clamped(Gfx::IntPoint position) const return glyph; } +void GlyphMapWidget::context_menu_event(GUI::ContextMenuEvent& event) +{ + if (on_context_menu_request) + on_context_menu_request(event); +} + void GlyphMapWidget::mousedown_event(MouseEvent& event) { + if (event.button() == MouseButton::Secondary) + return; + if (auto maybe_glyph = glyph_at_position(event.position()); maybe_glyph.has_value()) { auto glyph = maybe_glyph.value(); if (event.shift()) @@ -196,6 +205,9 @@ void GlyphMapWidget::mousedown_event(MouseEvent& event) void GlyphMapWidget::mouseup_event(GUI::MouseEvent& event) { + if (event.button() == MouseButton::Secondary) + return; + if (!m_in_drag_select) return; auto constrained = event.position().constrained(widget_inner_rect()); diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.h b/Userland/Libraries/LibGUI/GlyphMapWidget.h index 66afecf806..d72a2345de 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.h +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.h @@ -68,6 +68,7 @@ public: Function<void(int)> on_active_glyph_changed; Function<void(int)> on_glyph_double_clicked; + Function<void(ContextMenuEvent&)> on_context_menu_request; private: GlyphMapWidget(); @@ -79,6 +80,7 @@ private: virtual void keydown_event(KeyEvent&) override; virtual void resize_event(ResizeEvent&) override; virtual void did_change_font() override; + virtual void context_menu_event(ContextMenuEvent&) override; Gfx::IntRect get_outer_rect(int glyph) const; Optional<int> glyph_at_position(Gfx::IntPoint) const; |