Skip to content

Commit f2ac858

Browse files
committed
pauseEvent / resumeEvent on Screen.instance
1 parent dd717ec commit f2ac858

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

haxe/ui/core/Screen.hx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,32 @@ class Screen extends ScreenImpl {
335335
}
336336

337337
private function _onMappedEvent(event:UIEvent) {
338+
if (_pausedEvents != null && _pausedEvents.indexOf(event.type) != -1) {
339+
return;
340+
}
341+
338342
_eventMap.invoke(event.type, event);
339343
}
344+
345+
@:noCompletion private var _pausedEvents:Array<String> = null;
346+
public function pauseEvent(type:String) {
347+
if (_pausedEvents == null) {
348+
_pausedEvents = [];
349+
}
350+
if (_pausedEvents.indexOf(type) == -1) {
351+
_pausedEvents.push(type);
352+
}
353+
}
354+
355+
public function resumeEvent(type:String, nextFrame:Bool = false) {
356+
if (nextFrame) {
357+
Toolkit.callLater(function() {
358+
resumeEvent(type, false);
359+
});
360+
} else {
361+
if (_pausedEvents != null && _pausedEvents.indexOf(type) != -1) {
362+
_pausedEvents.remove(type);
363+
}
364+
}
365+
}
340366
}

0 commit comments

Comments
 (0)