diff options
author | Karol Kosek <krkk@krkk.ct8.pl> | 2021-09-12 17:45:38 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-12 20:20:18 +0200 |
commit | 71185f91a826c0966fbcb6bed5ca9392163089e4 (patch) | |
tree | 9f0d07aa7260f74b8a00badba3c97bfeefaba1d4 /Userland/Libraries | |
parent | 3c6ad4c7db054257af4bbeec407a06b4f9497489 (diff) | |
download | serenity-71185f91a826c0966fbcb6bed5ca9392163089e4.zip |
LibGUI: Enable/Disable the Open button on text change in FilePicker
Prior this change, the button was updated on user selection change
in the file view.
This isn't quite right, as you could remove the text from the text box
or (even worse) start typing a filename there and the button state
wouldn't change.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/FilePicker.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index 380b207a4e..a98993333b 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -187,7 +187,11 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen done(ExecCancel); }; - m_view->on_selection_change = [this, &ok_button] { + m_filename_textbox->on_change = [&] { + ok_button.set_enabled(!m_filename_textbox->text().is_empty()); + }; + + m_view->on_selection_change = [this] { auto index = m_view->selection().first(); auto& filter_model = (SortingProxyModel&)*m_view->model(); auto local_index = filter_model.map_to_source(index); @@ -199,7 +203,6 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen } else if (m_mode != Mode::Save) { m_filename_textbox->clear(); } - ok_button.set_enabled(!m_filename_textbox->text().is_empty()); }; m_view->on_activation = [this](auto& index) { |