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
159159 auto result = listener.func .get ().call ({}, __VA_ARGS__); \
160160 if (result.isBoolean () && result.asBoolean ().value () == false ) { \
161161 ev.cancel (); \
162- return ; \
163162 } \
164163 } \
165164 LISTENER_CATCH (TYPE) \
@@ -168,25 +167,33 @@ inline std::string EventTypeToString(EVENT_TYPES e) { return std::string(magic_e
168167// 调用事件监听函数,拦截返回RETURN_VALUE
169168#define CallEventRtnValue (TYPE, RETURN_VALUE, ...) \
170169 std::list<ListenerListType>& nowList = listenerList[int (TYPE)]; \
170+ bool isCancelled; \
171171 for (auto & listener : nowList) { \
172172 EngineScope enter (listener.engine ); \
173173 try { \
174174 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 ; \
176176 } \
177177 LISTENER_CATCH (TYPE) \
178+ } \
179+ if (isCancelled) { \
180+ return RETURN_VALUE; \
178181 }
179182
180183// 调用事件监听函数,拦截返回
181184#define CallEventVoid (TYPE, ...) \
182185 std::list<ListenerListType>& nowList = listenerList[int (TYPE)]; \
186+ bool isCancelled; \
183187 for (auto & listener : nowList) { \
184188 EngineScope enter (listener.engine ); \
185189 try { \
186190 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 ; \
188192 } \
189193 LISTENER_CATCH (TYPE) \
194+ } \
195+ if (isCancelled) { \
196+ return ; \
190197 }
191198
192199// 调用事件监听函数,不可拦截
You can’t perform that action at this time.
0 commit comments