mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 01:59:14 +03:00
Userland: Use default buttons instead of manually handling return press
Besides simplifying the code, this will also draw outline for these buttons as a cue for a user!
This commit is contained in:
parent
a232395b77
commit
9f1f1b8472
Notes:
sideshowbarker
2024-07-17 10:30:10 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/9f1f1b8472 Pull-request: https://github.com/SerenityOS/serenity/pull/14172 Reviewed-by: https://github.com/AtkinsSJ ✅
@ -57,20 +57,15 @@ private:
|
||||
m_title_textbox->set_text(title);
|
||||
m_title_textbox->set_focus(true);
|
||||
m_title_textbox->select_all();
|
||||
m_title_textbox->on_return_pressed = [this] {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
|
||||
m_url_textbox = *widget.find_descendant_of_type_named<GUI::TextBox>("url_textbox");
|
||||
m_url_textbox->set_text(url);
|
||||
m_url_textbox->on_return_pressed = [this] {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
|
||||
auto& ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok_button");
|
||||
ok_button.on_click = [this](auto) {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
ok_button.set_default(true);
|
||||
|
||||
auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
|
||||
cancel_button.on_click = [this](auto) {
|
||||
|
@ -130,10 +130,6 @@ FindDialog::FindDialog()
|
||||
m_find_all_button->set_enabled(!m_text_editor->text().is_empty());
|
||||
};
|
||||
|
||||
m_text_editor->on_return_pressed = [this] {
|
||||
m_find_button->click();
|
||||
};
|
||||
|
||||
m_find_button->on_click = [this](auto) {
|
||||
auto text = m_text_editor->text();
|
||||
if (!text.is_empty()) {
|
||||
@ -141,6 +137,7 @@ FindDialog::FindDialog()
|
||||
done(ExecResult::OK);
|
||||
}
|
||||
};
|
||||
m_find_button->set_default(true);
|
||||
|
||||
m_find_all_button->on_click = [this](auto) {
|
||||
m_find_all = true;
|
||||
|
@ -119,13 +119,10 @@ GoToOffsetDialog::GoToOffsetDialog()
|
||||
m_offset_from_box->set_selected_index(0);
|
||||
m_offset_from_box->set_only_allow_values_from_model(true);
|
||||
|
||||
m_text_editor->on_return_pressed = [this] {
|
||||
m_go_button->click();
|
||||
};
|
||||
|
||||
m_go_button->on_click = [this](auto) {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
m_go_button->set_default(true);
|
||||
|
||||
m_text_editor->on_change = [this]() {
|
||||
auto text = m_text_editor->text();
|
||||
|
@ -54,6 +54,7 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
|
||||
ok_button.on_click = [this](auto) {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
ok_button.set_default(true);
|
||||
|
||||
auto& cancel_button = button_container.add<GUI::Button>("Cancel");
|
||||
cancel_button.on_click = [this](auto) {
|
||||
@ -68,10 +69,6 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
|
||||
m_image_size.set_height(value);
|
||||
};
|
||||
|
||||
m_name_textbox->on_return_pressed = [this] {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
|
||||
width_spinbox.set_range(1, 16384);
|
||||
height_spinbox.set_range(1, 16384);
|
||||
|
||||
|
@ -53,6 +53,7 @@ CreateNewLayerDialog::CreateNewLayerDialog(Gfx::IntSize const& suggested_size, G
|
||||
ok_button.on_click = [this](auto) {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
ok_button.set_default(true);
|
||||
|
||||
auto& cancel_button = button_container.add<GUI::Button>("Cancel");
|
||||
cancel_button.on_click = [this](auto) {
|
||||
@ -67,10 +68,6 @@ CreateNewLayerDialog::CreateNewLayerDialog(Gfx::IntSize const& suggested_size, G
|
||||
m_layer_size.set_height(value);
|
||||
};
|
||||
|
||||
m_name_textbox->on_return_pressed = [this] {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
|
||||
width_spinbox.set_range(1, 16384);
|
||||
height_spinbox.set_range(1, 16384);
|
||||
|
||||
|
@ -48,9 +48,6 @@ ResizeImageDialog::ResizeImageDialog(Gfx::IntSize const& suggested_size, GUI::Wi
|
||||
}
|
||||
m_desired_size.set_width(value);
|
||||
};
|
||||
width_spinbox->on_return_pressed = [this]() {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
|
||||
height_spinbox->set_value(m_desired_size.height());
|
||||
height_spinbox->on_change = [this, width_spinbox, keep_aspect_ratio_checkbox](int value) {
|
||||
@ -61,9 +58,6 @@ ResizeImageDialog::ResizeImageDialog(Gfx::IntSize const& suggested_size, GUI::Wi
|
||||
}
|
||||
m_desired_size.set_height(value);
|
||||
};
|
||||
height_spinbox->on_return_pressed = [this]() {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
|
||||
keep_aspect_ratio_checkbox->on_checked = [this, height_spinbox](bool is_checked) {
|
||||
if (is_checked) {
|
||||
@ -102,6 +96,7 @@ ResizeImageDialog::ResizeImageDialog(Gfx::IntSize const& suggested_size, GUI::Wi
|
||||
ok_button->on_click = [this](auto) {
|
||||
done(ExecResult::OK);
|
||||
};
|
||||
ok_button->set_default(true);
|
||||
|
||||
cancel_button->on_click = [this](auto) {
|
||||
done(ExecResult::Cancel);
|
||||
|
@ -48,14 +48,12 @@ RunWindow::RunWindow()
|
||||
m_path_combo_box = *main_widget.find_descendant_of_type_named<GUI::ComboBox>("path");
|
||||
m_path_combo_box->set_model(m_path_history_model);
|
||||
m_path_combo_box->set_selected_index(0);
|
||||
m_path_combo_box->on_return_pressed = [this] {
|
||||
m_ok_button->click();
|
||||
};
|
||||
|
||||
m_ok_button = *main_widget.find_descendant_of_type_named<GUI::Button>("ok_button");
|
||||
m_ok_button->on_click = [this](auto) {
|
||||
do_run();
|
||||
};
|
||||
m_ok_button->set_default(true);
|
||||
|
||||
m_cancel_button = *main_widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
|
||||
m_cancel_button->on_click = [this](auto) {
|
||||
|
@ -71,21 +71,14 @@ NewProjectDialog::NewProjectDialog(GUI::Window* parent)
|
||||
m_name_input->on_change = [&]() {
|
||||
update_dialog();
|
||||
};
|
||||
m_name_input->on_return_pressed = [&]() {
|
||||
if (m_input_valid)
|
||||
do_create_project();
|
||||
};
|
||||
m_create_in_input = *main_widget.find_descendant_of_type_named<GUI::TextBox>("create_in_input");
|
||||
m_create_in_input->on_change = [&]() {
|
||||
update_dialog();
|
||||
};
|
||||
m_create_in_input->on_return_pressed = [&]() {
|
||||
if (m_input_valid)
|
||||
do_create_project();
|
||||
};
|
||||
m_full_path_label = *main_widget.find_descendant_of_type_named<GUI::Label>("full_path_label");
|
||||
|
||||
m_ok_button = *main_widget.find_descendant_of_type_named<GUI::Button>("ok_button");
|
||||
m_ok_button->set_default(true);
|
||||
m_ok_button->on_click = [this](auto) {
|
||||
do_create_project();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user