File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,6 @@ inline std::string EventTypeToString(EVENT_TYPES e) { return std::string(magic_e
159
159
auto result = listener.func .get ().call ({}, __VA_ARGS__); \
160
160
if (result.isBoolean () && result.asBoolean ().value () == false ) { \
161
161
ev.cancel (); \
162
- return ; \
163
162
} \
164
163
} \
165
164
LISTENER_CATCH (TYPE) \
@@ -168,25 +167,33 @@ inline std::string EventTypeToString(EVENT_TYPES e) { return std::string(magic_e
168
167
// 调用事件监听函数,拦截返回RETURN_VALUE
169
168
#define CallEventRtnValue (TYPE, RETURN_VALUE, ...) \
170
169
std::list<ListenerListType>& nowList = listenerList[int (TYPE)]; \
170
+ bool isCancelled; \
171
171
for (auto & listener : nowList) { \
172
172
EngineScope enter (listener.engine ); \
173
173
try { \
174
174
auto result = listener.func .get ().call ({}, __VA_ARGS__); \
175
- if (result.isBoolean () && result.asBoolean ().value () == false ) return RETURN_VALUE; \
175
+ if (result.isBoolean () && result.asBoolean ().value () == false ) isCancelled = true ; \
176
176
} \
177
177
LISTENER_CATCH (TYPE) \
178
+ } \
179
+ if (isCancelled) { \
180
+ return RETURN_VALUE; \
178
181
}
179
182
180
183
// 调用事件监听函数,拦截返回
181
184
#define CallEventVoid (TYPE, ...) \
182
185
std::list<ListenerListType>& nowList = listenerList[int (TYPE)]; \
186
+ bool isCancelled; \
183
187
for (auto & listener : nowList) { \
184
188
EngineScope enter (listener.engine ); \
185
189
try { \
186
190
auto result = listener.func .get ().call ({}, __VA_ARGS__); \
187
- if (result.isBoolean () && result.asBoolean ().value () == false ) return ; \
191
+ if (result.isBoolean () && result.asBoolean ().value () == false ) isCancelled = true ; \
188
192
} \
189
193
LISTENER_CATCH (TYPE) \
194
+ } \
195
+ if (isCancelled) { \
196
+ return ; \
190
197
}
191
198
192
199
// 调用事件监听函数,不可拦截
You can’t perform that action at this time.
0 commit comments