mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibGUI: Remove Button& parameter from Button::on_click hook
There was but a single user of this parameter and it's a bit tedious to write it out every time, so let's get rid of it.
This commit is contained in:
parent
b1d35248e4
commit
a26b63a958
26 changed files with 60 additions and 55 deletions
|
@ -83,7 +83,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::
|
|||
auto ok_button = button_container->add<Button>("OK");
|
||||
ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
ok_button->set_preferred_size(80, 20);
|
||||
ok_button->on_click = [this](auto&) {
|
||||
ok_button->on_click = [this] {
|
||||
done(Dialog::ExecOK);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ void Button::click()
|
|||
set_checked(!is_checked());
|
||||
}
|
||||
if (on_click)
|
||||
on_click(*this);
|
||||
on_click();
|
||||
if (m_action)
|
||||
m_action->activate(this);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
void set_text_alignment(Gfx::TextAlignment text_alignment) { m_text_alignment = text_alignment; }
|
||||
Gfx::TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
|
||||
Function<void(Button&)> on_click;
|
||||
Function<void()> on_click;
|
||||
|
||||
void set_button_style(Gfx::ButtonStyle style) { m_button_style = style; }
|
||||
Gfx::ButtonStyle button_style() const { return m_button_style; }
|
||||
|
|
|
@ -75,13 +75,13 @@ void ColorPicker::build()
|
|||
auto cancel_button = right_vertical_container->add<Button>("Cancel");
|
||||
cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
cancel_button->set_preferred_size(0, 20);
|
||||
cancel_button->on_click = [&](auto&) {
|
||||
cancel_button->on_click = [&] {
|
||||
done(Dialog::ExecCancel);
|
||||
};
|
||||
auto ok_button = right_vertical_container->add<Button>("Okay");
|
||||
ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
ok_button->set_preferred_size(0, 20);
|
||||
ok_button->on_click = [&](auto&) {
|
||||
ok_button->on_click = [&] {
|
||||
done(Dialog::ExecOK);
|
||||
};
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ ComboBox::ComboBox()
|
|||
m_open_button = add<Button>();
|
||||
m_open_button->set_focusable(false);
|
||||
m_open_button->set_text("\xc3\xb7");
|
||||
m_open_button->on_click = [this](auto&) {
|
||||
m_open_button->on_click = [this] {
|
||||
if (m_list_window->is_visible())
|
||||
close();
|
||||
else
|
||||
|
|
|
@ -210,7 +210,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
cancel_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
cancel_button->set_preferred_size(80, 0);
|
||||
cancel_button->set_text("Cancel");
|
||||
cancel_button->on_click = [this](auto&) {
|
||||
cancel_button->on_click = [this] {
|
||||
done(ExecCancel);
|
||||
};
|
||||
|
||||
|
@ -218,7 +218,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
ok_button->set_preferred_size(80, 0);
|
||||
ok_button->set_text(ok_button_name(m_mode));
|
||||
ok_button->on_click = [this](auto&) {
|
||||
ok_button->on_click = [this] {
|
||||
on_file_return();
|
||||
};
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ void InputBox::build()
|
|||
m_cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_cancel_button->set_preferred_size(0, 20);
|
||||
m_cancel_button->set_text("Cancel");
|
||||
m_cancel_button->on_click = [this](auto&) {
|
||||
m_cancel_button->on_click = [this] {
|
||||
dbgprintf("GInputBox: Cancel button clicked\n");
|
||||
done(ExecCancel);
|
||||
};
|
||||
|
@ -93,7 +93,7 @@ void InputBox::build()
|
|||
m_ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_ok_button->set_preferred_size(0, 20);
|
||||
m_ok_button->set_text("OK");
|
||||
m_ok_button->on_click = [this](auto&) {
|
||||
m_ok_button->on_click = [this] {
|
||||
dbgprintf("GInputBox: OK button clicked\n");
|
||||
m_text_value = m_text_editor->text();
|
||||
done(ExecOK);
|
||||
|
|
|
@ -131,7 +131,7 @@ void MessageBox::build()
|
|||
button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
button->set_preferred_size(0, 20);
|
||||
button->set_text(label);
|
||||
button->on_click = [this, label, result](auto&) {
|
||||
button->on_click = [this, label, result] {
|
||||
dbg() << "GUI::MessageBox: '" << label << "' button clicked";
|
||||
done(result);
|
||||
};
|
||||
|
|
|
@ -45,12 +45,12 @@ SpinBox::SpinBox()
|
|||
m_increment_button = add<Button>();
|
||||
m_increment_button->set_focusable(false);
|
||||
m_increment_button->set_text("\xc3\xb6");
|
||||
m_increment_button->on_click = [this](auto&) { set_value(m_value + 1); };
|
||||
m_increment_button->on_click = [this] { set_value(m_value + 1); };
|
||||
m_increment_button->set_auto_repeat_interval(150);
|
||||
m_decrement_button = add<Button>();
|
||||
m_decrement_button->set_focusable(false);
|
||||
m_decrement_button->set_text("\xc3\xb7");
|
||||
m_decrement_button->on_click = [this](auto&) { set_value(m_value - 1); };
|
||||
m_decrement_button->on_click = [this] { set_value(m_value - 1); };
|
||||
m_decrement_button->set_auto_repeat_interval(150);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue