MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / init

Method init

Source/Node/Menu.cpp:37–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37bool Menu::init() {
38 if (!Node::init()) return false;
39 slot("TapFilter"_slice, [&](Event* e) {
40 Touch* touch = nullptr;
41 if (!e->get(touch)) return;
42 if (_selectedItem || !_enabled) {
43 touch->setEnabled(false);
44 }
45 });
46 slot("TapBegan"_slice, [&](Event* e) {
47 Touch* touch = nullptr;
48 if (!e->get(touch)) return;
49 _selectedItem = itemForTouch(touch);
50 if (_selectedItem) {
51 _selectedItem->emit("TapBegan"_slice, touch);
52 } else
53 touch->setEnabled(false);
54 });
55 slot("TapMoved"_slice, [&](Event* e) {
56 Touch* touch = nullptr;
57 if (!e->get(touch)) return;
58 Node* currentItem = itemForTouch(touch);
59 if (!_enabled) {
60 if (currentItem && currentItem == _selectedItem) {
61 _selectedItem->emit("TapEnded"_slice, touch);
62 _selectedItem = nullptr;
63 }
64 return;
65 }
66 if (currentItem != _selectedItem) {
67 if (_selectedItem) {
68 _selectedItem->emit("TapEnded"_slice, touch);
69 }
70 _selectedItem = currentItem;
71 if (currentItem) {
72 currentItem->emit("TapBegan"_slice, touch);
73 }
74 } else if (currentItem) {
75 currentItem->emit("TapMoved"_slice, touch);
76 }
77 });
78 slot("TapEnded"_slice, [&](Event* e) {
79 Touch* touch = nullptr;
80 if (!e->get(touch)) return;
81 if (_selectedItem) {
82 _selectedItem->emit("TapEnded"_slice, touch);
83 if (_enabled) {
84 _selectedItem->emit("Tapped"_slice, touch);
85 }
86 _selectedItem = nullptr;
87 }
88 });
89 return true;
90}
91
92static Node* getTouchedItem(Node* parentItem, const Vec2& worldLocation) {
93 Array* children = parentItem->getChildren();

Callers 10

_buildArmatureMethod · 0.45
_buildSlotMethod · 0.45
initThreadOnceMethod · 0.45
initRuntimeFunction · 0.45
createContextFunction · 0.45
tic80.jsFile · 0.45
i18n.tsFile · 0.45
DisplayFunction · 0.45

Calls 4

getMethod · 0.65
initFunction · 0.50
setEnabledMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected