Hide file dialog confirm button when appropriate

This commit is contained in:
Nikita Lisitsa 2023-01-04 17:09:31 +03:00
parent d60eb6f659
commit 594dcc9230

View file

@ -159,6 +159,8 @@ namespace psemek::ui
auto confirm_button = options.element_factory.make_button(options.type == file_dialog_type::save ? "Save" : "Open"); auto confirm_button = options.element_factory.make_button(options.type == file_dialog_type::save ? "Save" : "Open");
auto cancel_button = options.element_factory.make_button("Cancel"); auto cancel_button = options.element_factory.make_button("Cancel");
confirm_button->set_hidden(true);
bottom_layout->set(0, 1, status_label); bottom_layout->set(0, 1, status_label);
bottom_layout->set(0, 2, confirm_button); bottom_layout->set(0, 2, confirm_button);
bottom_layout->set(0, 3, cancel_button); bottom_layout->set(0, 3, cancel_button);
@ -301,6 +303,7 @@ namespace psemek::ui
path_edit->on_text_entered([=](std::u32string_view const & text_u32){ path_edit->on_text_entered([=](std::u32string_view const & text_u32){
std::string text = util::to_utf8(std::u32string(text_u32)); std::string text = util::to_utf8(std::u32string(text_u32));
*selected_path = *current_path / text; *selected_path = *current_path / text;
confirm_button->set_hidden(text.empty());
}, false); }, false);
cancel_button->on_click([=]{ cancel_button->on_click([=]{