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.
This commit is contained in:
Karol Kosek 2021-09-12 17:45:38 +02:00 committed by Andreas Kling
parent 3c6ad4c7db
commit 71185f91a8
Notes: sideshowbarker 2024-07-19 17:13:26 +09:00

View file

@ -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) {