feat: Added event canceling
This commit is contained in:
@@ -28,9 +28,16 @@ def callEvent(evtName : str, **kwargs : dict):
|
||||
g2o.callEvent('testEvt', name = 'Diego')
|
||||
```
|
||||
"""
|
||||
|
||||
isEventCancelled = False
|
||||
|
||||
if evtName in eventList:
|
||||
for event in eventList[evtName]:
|
||||
event['function'](**kwargs)
|
||||
result = event['function'](**kwargs)
|
||||
if result != None:
|
||||
isEventCancelled = not result
|
||||
|
||||
return isEventCancelled
|
||||
|
||||
def addEvent(name : str):
|
||||
"""
|
||||
|
||||
@@ -33,8 +33,11 @@ void callEvent(const char* eventName, py::dict kwargs)
|
||||
{
|
||||
try
|
||||
{
|
||||
g2o.attr("callEvent")(eventName, **kwargs);
|
||||
|
||||
bool result = g2o.attr("callEvent")(eventName, **kwargs).cast<bool>();
|
||||
if (result)
|
||||
{
|
||||
Sqrat::RootTable().GetFunction("cancelEvent").Execute();
|
||||
}
|
||||
}
|
||||
catch (py::error_already_set &e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user