summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-02-17 11:20:12 +0000
committerLinus Groh <mail@linusgroh.de>2023-02-19 01:09:09 +0100
commit5b77346f53774fac4c9cebb73e820dafd63aaf0d (patch)
tree52d6d8ad7849be87651be7a5eabab298b8dc94e8 /Userland
parent8f717927f29400a0e73309bb1b0d64f4f40787a1 (diff)
downloadserenity-5b77346f53774fac4c9cebb73e820dafd63aaf0d.zip
LibGUI: Allow double-clicking PathBreadcrumbbar buttons to edit path
When viewing a deeply nested path, there may be very little of the PathBreadcrumbbar itself visible to double-click on. This solves that by allowing double-clicks on its segment buttons to behave the same. (With the caveat that it first selects the double-clicked segment.) In order to make this work, `on_double_click` now takes the modifiers instead of the MouseEvent. In this case we don't use it so that's fine, but maybe we should make all mouse callbacks consistently take the MouseEvent& as a parameter.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGUI/Breadcrumbbar.cpp6
-rw-r--r--Userland/Libraries/LibGUI/Breadcrumbbar.h2
-rw-r--r--Userland/Libraries/LibGUI/PathBreadcrumbbar.cpp2
3 files changed, 7 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp
index a8db7bf70f..0b320704c3 100644
--- a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp
+++ b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp
@@ -86,6 +86,10 @@ void Breadcrumbbar::append_segment(DeprecatedString text, Gfx::Bitmap const* ico
if (on_segment_change && m_selected_segment != index)
on_segment_change(index);
};
+ button.on_double_click = [this](auto modifiers) {
+ if (on_doubleclick)
+ on_doubleclick(modifiers);
+ };
button.on_focus_change = [this, index = m_segments.size()](auto has_focus, auto) {
if (has_focus && on_segment_change && m_selected_segment != index)
on_segment_change(index);
@@ -154,7 +158,7 @@ void Breadcrumbbar::set_selected_segment(Optional<size_t> index)
void Breadcrumbbar::doubleclick_event(MouseEvent& event)
{
if (on_doubleclick)
- on_doubleclick(event);
+ on_doubleclick(event.modifiers());
}
void Breadcrumbbar::resize_event(ResizeEvent&)
diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.h b/Userland/Libraries/LibGUI/Breadcrumbbar.h
index 2122ec1a7b..0a16334194 100644
--- a/Userland/Libraries/LibGUI/Breadcrumbbar.h
+++ b/Userland/Libraries/LibGUI/Breadcrumbbar.h
@@ -37,7 +37,7 @@ public:
Function<void(size_t index)> on_segment_click;
Function<void(size_t index, DropEvent&)> on_segment_drop;
Function<void(size_t index, DragEvent&)> on_segment_drag_enter;
- Function<void(MouseEvent& event)> on_doubleclick;
+ Function<void(unsigned modifiers)> on_doubleclick;
protected:
virtual void did_change_font() override;
diff --git a/Userland/Libraries/LibGUI/PathBreadcrumbbar.cpp b/Userland/Libraries/LibGUI/PathBreadcrumbbar.cpp
index f44b472065..78988a3df3 100644
--- a/Userland/Libraries/LibGUI/PathBreadcrumbbar.cpp
+++ b/Userland/Libraries/LibGUI/PathBreadcrumbbar.cpp
@@ -80,7 +80,7 @@ PathBreadcrumbbar::PathBreadcrumbbar(NonnullRefPtr<GUI::TextBox> location_text_b
on_paths_drop(m_breadcrumbbar->segment_data(segment_index), event);
};
- m_breadcrumbbar->on_doubleclick = [&](GUI::MouseEvent const&) {
+ m_breadcrumbbar->on_doubleclick = [&](auto) {
show_location_text_box();
};
}