mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 01:41:59 -05:00
LibGUI: Don't highlight extension text when saving files with FilePicker
By default, only highlight the base name of the file to-be-saved. When the file includes an extension, it's useful to be able to just start typing a file name without having to manually de-select the extension (or having to rewrite the extension).
This commit is contained in:
parent
0fe4f4fe53
commit
ee95cb37cd
1 changed files with 10 additions and 1 deletions
|
@ -153,8 +153,17 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St
|
|||
m_filename_textbox = *widget.find_descendant_of_type_named<GUI::TextBox>("filename_textbox");
|
||||
m_filename_textbox->set_focus(true);
|
||||
if (m_mode == Mode::Save) {
|
||||
LexicalPath lexical_filename { filename };
|
||||
m_filename_textbox->set_text(filename);
|
||||
m_filename_textbox->select_all();
|
||||
|
||||
if (auto extension = lexical_filename.extension(); !extension.is_empty()) {
|
||||
TextPosition start_of_filename { 0, 0 };
|
||||
TextPosition end_of_filename { 0, filename.length() - extension.length() - 1 };
|
||||
|
||||
m_filename_textbox->set_selection({ end_of_filename, start_of_filename });
|
||||
} else {
|
||||
m_filename_textbox->select_all();
|
||||
}
|
||||
}
|
||||
m_filename_textbox->on_return_pressed = [&] {
|
||||
on_file_return();
|
||||
|
|
Loading…
Reference in a new issue