mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-14 22:31:29 +03:00
7a0a7abc52
auto* b = new Button; b->onClick = [] (Button&) { printf("The button was clicked!\n"); };
27 lines
600 B
C++
27 lines
600 B
C++
#pragma once
|
|
|
|
#include "Widget.h"
|
|
#include <AK/String.h>
|
|
|
|
class Button final : public Widget {
|
|
public:
|
|
explicit Button(Widget* parent);
|
|
virtual ~Button() override;
|
|
|
|
String caption() const { return m_caption; }
|
|
void setCaption(String&&);
|
|
|
|
std::function<void(Button&)> onClick;
|
|
|
|
private:
|
|
virtual void paintEvent(PaintEvent&) override;
|
|
virtual void mouseDownEvent(MouseEvent&) override;
|
|
virtual void mouseUpEvent(MouseEvent&) override;
|
|
|
|
virtual const char* className() const override { return "Button"; }
|
|
|
|
String m_caption;
|
|
bool m_beingPressed { false };
|
|
};
|
|
|