1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 14:17:34 +00: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:
Karol Kosek 2022-05-27 19:36:06 +02:00 committed by Andreas Kling
parent a232395b77
commit 9f1f1b8472
8 changed files with 8 additions and 39 deletions

View file

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

View file

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

View file

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