LibGUI: Include keyboard modifier state with button on_click calls

This will allow you us to implement special behavior when Ctrl+clicking
a button.
This commit is contained in:
Andreas Kling 2020-05-12 20:30:33 +02:00
parent 3a905aed06
commit 977863ea07
Notes: sideshowbarker 2024-07-19 06:42:03 +09:00
37 changed files with 76 additions and 76 deletions

View File

@ -117,7 +117,7 @@ int main(int argc, char** argv)
quit_button.set_text("Okay");
quit_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
quit_button.set_preferred_size(100, 20);
quit_button.on_click = [] {
quit_button.on_click = [](auto) {
GUI::Application::the().quit(0);
};

View File

@ -62,7 +62,7 @@ BookmarksBarWidget::BookmarksBarWidget(const String& bookmarks_file, bool enable
m_additional->set_text(">");
m_additional->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
m_additional->set_preferred_size(14, 20);
m_additional->on_click = [&] {
m_additional->on_click = [this](auto) {
if (m_additional_menu) {
m_additional_menu->popup(m_additional->relative_position().translated(relative_position().translated(m_additional->window()->position())));
}
@ -123,7 +123,7 @@ void BookmarksBarWidget::did_update_model()
button.set_preferred_size(font().width(title) + 32, 20);
button.set_relative_rect(rect);
button.on_click = [title, url, this] {
button.on_click = [title, url, this](auto) {
if (on_bookmark_click)
on_bookmark_click(title, url);
};
@ -166,7 +166,7 @@ void BookmarksBarWidget::update_content_size()
m_additional_menu->add_action(GUI::Action::create(bookmark.text(),
Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"),
[&](auto&) {
bookmark.on_click();
bookmark.on_click(0);
}));
}
}

View File

@ -31,9 +31,9 @@
#include <LibCore/File.h>
#include <LibCore/StandardPaths.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/Button.h>
#include <LibGUI/Label.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/ProgressBar.h>
#include <LibGUI/Window.h>
#include <LibProtocol/Client.h>
@ -106,7 +106,7 @@ DownloadWidget::DownloadWidget(const URL& url)
m_cancel_button = button_container.add<GUI::Button>("Cancel");
m_cancel_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
m_cancel_button->set_preferred_size(100, 22);
m_cancel_button->on_click = [this] {
m_cancel_button->on_click = [this](auto) {
bool success = m_download->stop();
ASSERT(success);
window()->close();
@ -116,7 +116,7 @@ DownloadWidget::DownloadWidget(const URL& url)
m_close_button->set_enabled(false);
m_close_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
m_close_button->set_preferred_size(100, 22);
m_close_button->on_click = [this] {
m_close_button->on_click = [this](auto) {
window()->close();
};
}

View File

@ -118,7 +118,7 @@ Tab::Tab()
m_bookmark_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
m_bookmark_button->set_preferred_size(22, 22);
m_bookmark_button->on_click = [this] {
m_bookmark_button->on_click = [this](auto) {
auto url = m_html_widget->main_frame().document()->url().to_string();
if (BookmarksBarWidget::the().contains_bookmark(url)) {
BookmarksBarWidget::the().remove_bookmark(url);

View File

@ -85,7 +85,7 @@ CalculatorWidget::CalculatorWidget()
m_clear_button = add<GUI::Button>();
m_clear_button->set_foreground_color(Color::NamedColor::Red);
m_clear_button->set_text("C");
m_clear_button->on_click = [this] {
m_clear_button->on_click = [this](auto) {
m_keypad.set_value(0.0);
m_calculator.clear_operation();
update_display();
@ -96,7 +96,7 @@ CalculatorWidget::CalculatorWidget()
m_clear_error_button = add<GUI::Button>();
m_clear_error_button->set_foreground_color(Color::NamedColor::Red);
m_clear_error_button->set_text("CE");
m_clear_error_button->on_click = [this] {
m_clear_error_button->on_click = [this](auto) {
m_calculator.clear_error();
update_display();
};
@ -106,7 +106,7 @@ CalculatorWidget::CalculatorWidget()
m_backspace_button = add<GUI::Button>();
m_backspace_button->set_foreground_color(Color::NamedColor::Red);
m_backspace_button->set_text("Backspace");
m_backspace_button->on_click = [this] {
m_backspace_button->on_click = [this](auto) {
m_keypad.type_backspace();
update_display();
};
@ -117,7 +117,7 @@ CalculatorWidget::CalculatorWidget()
m_decimal_point_button->move_to(133, 177);
m_decimal_point_button->set_foreground_color(Color::NamedColor::Blue);
m_decimal_point_button->set_text(".");
m_decimal_point_button->on_click = [this] {
m_decimal_point_button->on_click = [this](auto) {
m_keypad.type_decimal_point();
update_display();
};
@ -175,7 +175,7 @@ CalculatorWidget::CalculatorWidget()
m_equals_button->move_to(211, 177);
m_equals_button->set_foreground_color(Color::NamedColor::Red);
m_equals_button->set_text("=");
m_equals_button->on_click = [this] {
m_equals_button->on_click = [this](auto) {
double argument = m_keypad.value();
double res = m_calculator.finish_operation(argument);
m_keypad.set_value(res);
@ -191,7 +191,7 @@ CalculatorWidget::~CalculatorWidget()
void CalculatorWidget::add_button(GUI::Button& button, Calculator::Operation operation)
{
add_button(button);
button.on_click = [this, operation] {
button.on_click = [this, operation](auto) {
double argument = m_keypad.value();
double res = m_calculator.begin_operation(operation, argument);
m_keypad.set_value(res);
@ -203,7 +203,7 @@ void CalculatorWidget::add_button(GUI::Button& button, int digit)
{
add_button(button);
button.set_text(String::number(digit));
button.on_click = [this, digit] {
button.on_click = [this, digit](auto) {
m_keypad.type_digit(digit);
update_display();
};

View File

@ -107,7 +107,7 @@ AddEventDialog::AddEventDialog(RefPtr<Calendar> calendar, Core::DateTime date_ti
auto& ok_button = button_container.add<GUI::Button>("OK");
ok_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
ok_button.set_preferred_size(80, 20);
ok_button.on_click = [this] {
ok_button.on_click = [this](auto) {
dbg() << "TODO: Add event icon on specific tile";
done(Dialog::ExecOK);
};

View File

@ -64,7 +64,7 @@ CalendarWidget::CalendarWidget()
m_prev_month_button->set_font(Gfx::Font::default_bold_font());
m_prev_month_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
m_prev_month_button->set_preferred_size(40, 40);
m_prev_month_button->on_click = [this] {
m_prev_month_button->on_click = [this](auto) {
int m_target_month = m_calendar->selected_month() - 1;
int m_target_year = m_calendar->selected_year();
@ -79,7 +79,7 @@ CalendarWidget::CalendarWidget()
m_next_month_button->set_font(Gfx::Font::default_bold_font());
m_next_month_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
m_next_month_button->set_preferred_size(40, 40);
m_next_month_button->on_click = [this] {
m_next_month_button->on_click = [this](auto) {
int m_target_month = m_calendar->selected_month() + 1;
int m_target_year = m_calendar->selected_year();
@ -100,7 +100,7 @@ CalendarWidget::CalendarWidget()
m_add_event_button = top_right_container.add<GUI::Button>("Add Event");
m_add_event_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
m_add_event_button->set_preferred_size(100, 25);
m_add_event_button->on_click = [this] {
m_add_event_button->on_click = [this](auto) {
show_add_event_window();
};

View File

@ -146,7 +146,7 @@ void DisplaySettingsWidget::create_frame()
button.set_button_style(Gfx::ButtonStyle::CoolBar);
button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
button.set_preferred_size(22, 22);
button.on_click = [this]() {
button.on_click = [this](auto) {
Optional<String> open_path = GUI::FilePicker::get_open_filepath("Select wallpaper from file system.");
if (!open_path.has_value())
@ -240,7 +240,7 @@ void DisplaySettingsWidget::create_frame()
ok_button.set_text("OK");
ok_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
ok_button.set_preferred_size(60, 22);
ok_button.on_click = [this] {
ok_button.on_click = [this](auto) {
send_settings_to_window_server();
GUI::Application::the().quit();
};
@ -249,7 +249,7 @@ void DisplaySettingsWidget::create_frame()
cancel_button.set_text("Cancel");
cancel_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
cancel_button.set_preferred_size(60, 22);
cancel_button.on_click = [] {
cancel_button.on_click = [](auto) {
GUI::Application::the().quit();
};
@ -257,7 +257,7 @@ void DisplaySettingsWidget::create_frame()
apply_button.set_text("Apply");
apply_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
apply_button.set_preferred_size(60, 22);
apply_button.on_click = [this] {
apply_button.on_click = [this](auto) {
send_settings_to_window_server();
};
}

View File

@ -149,16 +149,16 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
button_widget.layout()->add_spacer();
make_button("OK", button_widget).on_click = [this] {
make_button("OK", button_widget).on_click = [this](auto) {
if (apply_changes())
close();
};
make_button("Cancel", button_widget).on_click = [this] {
make_button("Cancel", button_widget).on_click = [this](auto) {
close();
};
m_apply_button = make_button("Apply", button_widget);
m_apply_button->on_click = [this] { apply_changes(); };
m_apply_button->on_click = [this](auto) { apply_changes(); };
m_apply_button->set_enabled(false);
update();

View File

@ -219,7 +219,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite
save_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
save_button.set_preferred_size(80, 0);
save_button.set_text("Save");
save_button.on_click = [this] {
save_button.on_click = [this](auto) {
auto ret_val = m_edited_font->write_to_file(m_path);
if (!ret_val) {
GUI::MessageBox::show("The font file could not be saved.", "Save failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
@ -230,7 +230,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite
quit_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
quit_button.set_preferred_size(80, 0);
quit_button.set_text("Quit");
quit_button.on_click = [this] {
quit_button.on_click = [](auto) {
exit(0);
};

View File

@ -107,7 +107,7 @@ SamplerWidget::SamplerWidget(AudioEngine& audio_engine)
m_open_button->set_preferred_size(24, 24);
m_open_button->set_focusable(false);
m_open_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"));
m_open_button->on_click = [this] {
m_open_button->on_click = [this](auto) {
Optional<String> open_path = GUI::FilePicker::get_open_filepath();
if (!open_path.has_value())
return;

View File

@ -81,14 +81,14 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C
m_play = control_widget.add<GUI::Button>();
m_play->set_icon(*m_pause_icon);
m_play->set_enabled(false);
m_play->on_click = [this] {
m_play->on_click = [this](auto) {
m_play->set_icon(m_manager.toggle_pause() ? *m_play_icon : *m_pause_icon);
};
m_stop = control_widget.add<GUI::Button>();
m_stop->set_enabled(false);
m_stop->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/stop.png"));
m_stop->on_click = [this] { m_manager.stop(); };
m_stop->on_click = [this](auto) { m_manager.stop(); };
m_status = add<GUI::Label>();
m_status->set_frame_shape(Gfx::FrameShape::Box);

View File

@ -248,7 +248,7 @@ int main(int argc, char** argv)
if (first)
menu_option.set_checked(true);
menu_option.on_click = [content = &content, &stack] {
menu_option.on_click = [content = &content, &stack](auto) {
stack.set_active_widget(content);
content->invalidate_layout();
};

View File

@ -52,7 +52,7 @@ int main(int argc, char** argv)
button.set_text("Good-bye");
button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
button.set_preferred_size(0, 20);
button.on_click = [&] {
button.on_click = [&](auto) {
app.quit();
};

View File

@ -220,7 +220,7 @@ int main(int argc, char** argv)
auto& show_buton = tab_msgbox.add<GUI::Button>("Show");
show_buton.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
show_buton.set_preferred_size(0, 20);
show_buton.on_click = [&]() {
show_buton.on_click = [&](auto) {
GUI::MessageBox::show(content_textbox.text(), title_textbox.text(), msg_box_type, msg_box_input_type, window);
};

View File

@ -153,7 +153,7 @@ FindInFilesWidget::FindInFilesWidget()
current_editor().set_focus(true);
};
m_button->on_click = [this] {
m_button->on_click = [this](auto) {
auto results_model = find_in_files(m_textbox->text());
m_result_view->set_model(results_model);
};

View File

@ -112,7 +112,7 @@ RefPtr<GUI::Window> make_toolbox_window()
label_button.set_button_style(Gfx::ButtonStyle::CoolBar);
label_button.set_tooltip("GLabel");
label_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/label.png"));
label_button.on_click = [] {
label_button.on_click = [](auto) {
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GLabel);
};
@ -121,7 +121,7 @@ RefPtr<GUI::Window> make_toolbox_window()
button_button.set_button_style(Gfx::ButtonStyle::CoolBar);
button_button.set_tooltip("GButton");
button_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/button.png"));
button_button.on_click = [] {
button_button.on_click = [](auto) {
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GButton);
};
@ -129,7 +129,7 @@ RefPtr<GUI::Window> make_toolbox_window()
spinbox_button.set_button_style(Gfx::ButtonStyle::CoolBar);
spinbox_button.set_tooltip("GSpinBox");
spinbox_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
spinbox_button.on_click = [] {
spinbox_button.on_click = [](auto) {
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GSpinBox);
};
@ -137,7 +137,7 @@ RefPtr<GUI::Window> make_toolbox_window()
editor_button.set_button_style(Gfx::ButtonStyle::CoolBar);
editor_button.set_tooltip("GTextEditor");
editor_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
editor_button.on_click = [] {
editor_button.on_click = [](auto) {
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GTextEditor);
};
@ -145,7 +145,7 @@ RefPtr<GUI::Window> make_toolbox_window()
progress_bar_button.set_button_style(Gfx::ButtonStyle::CoolBar);
progress_bar_button.set_tooltip("GProgressBar");
progress_bar_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
progress_bar_button.on_click = [] {
progress_bar_button.on_click = [](auto) {
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GProgressBar);
};
@ -153,7 +153,7 @@ RefPtr<GUI::Window> make_toolbox_window()
slider_button.set_button_style(Gfx::ButtonStyle::CoolBar);
slider_button.set_tooltip("GSlider");
slider_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
slider_button.on_click = [] {
slider_button.on_click = [](auto) {
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GSlider);
};
@ -161,7 +161,7 @@ RefPtr<GUI::Window> make_toolbox_window()
checkbox_button.set_button_style(Gfx::ButtonStyle::CoolBar);
checkbox_button.set_tooltip("GCheckBox");
checkbox_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
checkbox_button.on_click = [] {
checkbox_button.on_click = [](auto) {
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GCheckBox);
};
@ -169,7 +169,7 @@ RefPtr<GUI::Window> make_toolbox_window()
radiobutton_button.set_button_style(Gfx::ButtonStyle::CoolBar);
radiobutton_button.set_tooltip("GRadioButton");
radiobutton_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/filled-radio-circle.png"));
radiobutton_button.on_click = [] {
radiobutton_button.on_click = [](auto) {
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GRadioButton);
};
@ -177,7 +177,7 @@ RefPtr<GUI::Window> make_toolbox_window()
scrollbar_button.set_button_style(Gfx::ButtonStyle::CoolBar);
scrollbar_button.set_tooltip("GScrollBar");
scrollbar_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
scrollbar_button.on_click = [] {
scrollbar_button.on_click = [](auto) {
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GScrollBar);
};
@ -185,7 +185,7 @@ RefPtr<GUI::Window> make_toolbox_window()
groupbox_button.set_button_style(Gfx::ButtonStyle::CoolBar);
groupbox_button.set_tooltip("GGroupBox");
groupbox_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
groupbox_button.on_click = [] {
groupbox_button.on_click = [](auto) {
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GGroupBox);
};

View File

@ -147,7 +147,7 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b
set_fill_with_background_color(true);
reset();
m_face_button.on_click = [this] { reset(); };
m_face_button.on_click = [this](auto) { reset(); };
set_face(Face::Default);
{
@ -260,7 +260,7 @@ void Field::reset()
square.label->set_icon(square.has_mine ? m_mine_bitmap : nullptr);
if (!square.button) {
square.button = add<SquareButton>();
square.button->on_click = [this, &square] {
square.button->on_click = [this, &square](auto) {
on_square_clicked(square);
};
square.button->on_right_click = [this, &square] {

View File

@ -85,7 +85,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window
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] {
ok_button.on_click = [this](auto) {
done(Dialog::ExecOK);
};
}

View File

@ -134,7 +134,7 @@ void AbstractButton::mouseup_event(MouseEvent& event)
m_being_pressed = false;
update();
if (was_being_pressed && !was_auto_repeating)
click();
click(event.modifiers());
}
Widget::mouseup_event(event);
}
@ -154,7 +154,7 @@ void AbstractButton::leave_event(Core::Event&)
void AbstractButton::keydown_event(KeyEvent& event)
{
if (event.key() == KeyCode::Key_Return) {
click();
click(event.modifiers());
event.accept();
return;
}

View File

@ -52,7 +52,7 @@ public:
bool is_hovered() const { return m_hovered; }
bool is_being_pressed() const { return m_being_pressed; }
virtual void click() = 0;
virtual void click(unsigned modifiers = 0) = 0;
virtual bool accepts_focus() const override { return true; }
virtual bool is_uncheckable() const { return true; }

View File

@ -86,7 +86,7 @@ void Button::paint_event(PaintEvent& event)
paint_text(painter, text_rect, font, text_alignment());
}
void Button::click()
void Button::click(unsigned modifiers)
{
if (!is_enabled())
return;
@ -96,7 +96,7 @@ void Button::click()
set_checked(!is_checked());
}
if (on_click)
on_click();
on_click(modifiers);
if (m_action)
m_action->activate(this);
}

View File

@ -47,12 +47,12 @@ 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()> on_click;
Function<void(unsigned modifiers)> on_click;
void set_button_style(Gfx::ButtonStyle style) { m_button_style = style; }
Gfx::ButtonStyle button_style() const { return m_button_style; }
virtual void click() override;
virtual void click(unsigned modifiers = 0) override;
void set_action(Action&);

View File

@ -97,7 +97,7 @@ void CheckBox::paint_event(PaintEvent& event)
paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft);
}
void CheckBox::click()
void CheckBox::click(unsigned)
{
if (!is_enabled())
return;

View File

@ -35,7 +35,7 @@ class CheckBox : public AbstractButton {
public:
virtual ~CheckBox() override;
virtual void click() override;
virtual void click(unsigned modifiers = 0) override;
private:
explicit CheckBox(const StringView& = {});

View File

@ -49,7 +49,7 @@ public:
Function<void(const Color)> on_click;
protected:
virtual void click() override;
virtual void click(unsigned modifiers = 0) override;
virtual void doubleclick_event(GUI::MouseEvent&) override;
virtual void paint_event(PaintEvent&) override;
@ -136,7 +136,7 @@ void ColorPicker::build_ui()
ok_button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
ok_button.set_preferred_size(80, 0);
ok_button.set_text("OK");
ok_button.on_click = [this] {
ok_button.on_click = [this](auto) {
done(ExecOK);
};
@ -144,7 +144,7 @@ void ColorPicker::build_ui()
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] {
cancel_button.on_click = [this](auto) {
done(ExecCancel);
};
}
@ -368,7 +368,7 @@ void ColorButton::paint_event(PaintEvent& event)
}
}
void ColorButton::click()
void ColorButton::click(unsigned)
{
if (on_click)
on_click(m_color);

View File

@ -68,7 +68,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] {
m_open_button->on_click = [this](auto) {
if (m_list_window->is_visible())
close();
else

View File

@ -216,7 +216,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] {
cancel_button.on_click = [this](auto) {
done(ExecCancel);
};
@ -224,7 +224,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] {
ok_button.on_click = [this](auto) {
on_file_return();
};

View File

@ -83,7 +83,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] {
m_ok_button->on_click = [this](auto) {
dbgprintf("GUI::InputBox: OK button clicked\n");
m_text_value = m_text_editor->text();
done(ExecOK);
@ -93,7 +93,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] {
m_cancel_button->on_click = [this](auto) {
dbgprintf("GUI::InputBox: Cancel button clicked\n");
done(ExecCancel);
};

View File

@ -134,7 +134,7 @@ void MessageBox::build()
button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
button.set_preferred_size(96, 0);
button.set_text(label);
button.on_click = [this, label, result] {
button.on_click = [this, label, result](auto) {
done(result);
};
};

View File

@ -78,7 +78,7 @@ void RadioButton::for_each_in_group(Callback callback)
});
}
void RadioButton::click()
void RadioButton::click(unsigned)
{
if (!is_enabled())
return;

View File

@ -35,7 +35,7 @@ class RadioButton : public AbstractButton {
public:
virtual ~RadioButton() override;
virtual void click() override;
virtual void click(unsigned modifiers = 0) override;
protected:
explicit RadioButton(const StringView& text = {});

View File

@ -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] { set_value(m_value + 1); };
m_increment_button->on_click = [this](auto) { 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] { set_value(m_value - 1); };
m_decrement_button->on_click = [this](auto) { set_value(m_value - 1); };
m_decrement_button->set_auto_repeat_interval(150);
}

View File

@ -60,7 +60,7 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*)
auto& button = html_view.add<GUI::Button>(value());
int text_width = Gfx::Font::default_font().width(value());
button.set_relative_rect(0, 0, text_width + 20, 20);
button.on_click = [this] {
button.on_click = [this](auto) {
if (auto* form = first_ancestor_of_type<HTMLFormElement>()) {
// FIXME: Remove this const_cast once we have a non-const first_ancestor_of_type.
const_cast<HTMLFormElement*>(form)->submit(this);

View File

@ -102,13 +102,13 @@ PowerDialog::PowerDialog()
button_box.layout()->set_spacing(8);
auto& ok_button = button_box.add<GUI::Button>();
ok_button.on_click = [this] {
ok_button.on_click = [this](auto) {
done(ExecResult::ExecOK);
};
ok_button.set_text("OK");
auto& cancel_button = button_box.add<GUI::Button>();
cancel_button.on_click = [this] {
cancel_button.on_click = [this](auto) {
done(ExecResult::ExecCancel);
};
cancel_button.set_text("Cancel");

View File

@ -116,7 +116,7 @@ void TaskbarWindow::create_quick_launch_bar()
button.set_icon(Gfx::Bitmap::load_from_file(app_icon_path));
button.set_tooltip(name);
button.on_click = [app_executable] {
button.on_click = [app_executable](auto) {
pid_t pid = fork();
if (pid < 0) {
perror("fork");

View File

@ -50,7 +50,7 @@ Window& WindowList::ensure_window(const WindowIdentifier& identifier)
return *it->value;
auto window = make<Window>(identifier);
window->set_button(aid_create_button(identifier));
window->button()->on_click = [window = window.ptr(), identifier] {
window->button()->on_click = [window = window.ptr(), identifier](auto) {
if (window->is_minimized() || !window->is_active()) {
GUI::WindowServerConnection::the().post_message(Messages::WindowServer::WM_SetActiveWindow(identifier.client_id(), identifier.window_id()));
} else {