|
41 | 41 | #include <Geode/utils/casts.hpp> |
42 | 42 | #include <Geode/utils/function.hpp> |
43 | 43 | #include <Geode/utils/ZStringView.hpp> |
| 44 | +#include <Geode/ui/NodeEvent.hpp> |
44 | 45 |
|
45 | 46 | namespace geode { |
46 | 47 | class Layout; |
@@ -1152,6 +1153,46 @@ class CC_DLL CCNode : public CCObject |
1152 | 1153 | GEODE_DLL geode::comm::ListenerHandle* getEventListener(std::string_view id); |
1153 | 1154 | GEODE_DLL size_t getEventListenerCount(); |
1154 | 1155 |
|
| 1156 | + template <class Callback> |
| 1157 | + geode::comm::ListenerHandle* addOnEnterCallback( |
| 1158 | + Callback&& callback, |
| 1159 | + int priority = 0 |
| 1160 | + ) { |
| 1161 | + return this->addEventListener("", geode::NodeEvent(this, geode::NodeEventType::OnEnter), std::forward<Callback>(callback), priority); |
| 1162 | + } |
| 1163 | + |
| 1164 | + template <class Callback> |
| 1165 | + geode::comm::ListenerHandle* addOnEnterTransitionDidFinishCallback( |
| 1166 | + Callback&& callback, |
| 1167 | + int priority = 0 |
| 1168 | + ) { |
| 1169 | + return this->addEventListener("", geode::NodeEvent(this, geode::NodeEventType::OnEnterTransitionDidFinish), std::forward<Callback>(callback), priority); |
| 1170 | + } |
| 1171 | + |
| 1172 | + template <class Callback> |
| 1173 | + geode::comm::ListenerHandle* addOnExitCallback( |
| 1174 | + Callback&& callback, |
| 1175 | + int priority = 0 |
| 1176 | + ) { |
| 1177 | + return this->addEventListener("", geode::NodeEvent(this, geode::NodeEventType::OnExit), std::forward<Callback>(callback), priority); |
| 1178 | + } |
| 1179 | + |
| 1180 | + template <class Callback> |
| 1181 | + geode::comm::ListenerHandle* addOnExitTransitionDidStartCallback( |
| 1182 | + Callback&& callback, |
| 1183 | + int priority = 0 |
| 1184 | + ) { |
| 1185 | + return this->addEventListener("", geode::NodeEvent(this, geode::NodeEventType::OnExitTransitionDidStart), std::forward<Callback>(callback), priority); |
| 1186 | + } |
| 1187 | + |
| 1188 | + template <class Callback> |
| 1189 | + geode::comm::ListenerHandle* addCleanupCallback( |
| 1190 | + Callback&& callback, |
| 1191 | + int priority = 0 |
| 1192 | + ) { |
| 1193 | + return this->addEventListener("", geode::NodeEvent(this, geode::NodeEventType::OnCleanup), std::forward<Callback>(callback), priority); |
| 1194 | + } |
| 1195 | + |
1155 | 1196 | /** |
1156 | 1197 | * Get child at index. Checks bounds. A negative |
1157 | 1198 | * index will get the child starting from the end |
|
0 commit comments