MCPcopy Create free account
hub / github.com/RevoSucks/BM64Recomp / process_event

Method process_event

src/ui/elements/ui_clickable.cpp:12–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10 }
11
12 void Clickable::process_event(const Event &e) {
13 switch (e.type) {
14 case EventType::Click: {
15 if (is_enabled()) {
16 const EventClick &click = std::get<EventClick>(e.variant);
17 for (const auto &function : clicked_callbacks) {
18 function(click.x, click.y);
19 }
20 break;
21 }
22 }
23 case EventType::MouseButton: {
24 if (is_enabled()) {
25 const EventMouseButton &mousebutton = std::get<EventMouseButton>(e.variant);
26 if (mousebutton.button == MouseButton::Left && mousebutton.pressed) {
27 for (const auto &function : pressed_callbacks) {
28 function(mousebutton.x, mousebutton.y);
29 }
30 }
31 break;
32 }
33 }
34 case EventType::Hover:
35 set_style_enabled(hover_state, std::get<EventHover>(e.variant).active && is_enabled());
36 break;
37 case EventType::Enable:
38 {
39 bool enable_active = std::get<EventEnable>(e.variant).active;
40 set_style_enabled(disabled_state, !enable_active);
41 if (enable_active) {
42 set_cursor(Cursor::Pointer);
43 set_focusable(true);
44 }
45 else {
46 set_cursor(Cursor::None);
47 set_focusable(false);
48 }
49 }
50 break;
51 case EventType::Drag: {
52 if (is_enabled()) {
53 const EventDrag &drag = std::get<EventDrag>(e.variant);
54 for (const auto &function : dragged_callbacks) {
55 function(drag.x, drag.y, drag.phase);
56 }
57 break;
58 }
59 }
60 default:
61 break;
62 }
63 }
64
65 void Clickable::add_clicked_callback(std::function<void(float, float)> callback) {
66 clicked_callbacks.emplace_back(callback);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected