1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

LibGUI: Set Open/Save button as default in FilePicker

This makes it more obvious that enter will return the current
selection and prevents returning without a valid selection.
This commit is contained in:
thankyouverycool 2023-05-18 08:50:29 -04:00 committed by Andreas Kling
parent f823b297b4
commit 7a183ee568

View file

@ -221,9 +221,6 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St
m_filename_textbox->select_all();
}
}
m_filename_textbox->on_return_pressed = [&] {
on_file_return();
};
m_context_menu = GUI::Menu::construct();
@ -254,6 +251,11 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St
on_file_return();
};
ok_button.set_enabled(m_mode == Mode::OpenFolder || !m_filename_textbox->text().is_empty());
ok_button.set_default(true);
m_location_textbox->on_focus_change = [&ok_button](auto focused, auto) {
ok_button.set_default(!focused);
};
auto& cancel_button = *widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
cancel_button.set_text("Cancel"_short_string);