Skip to content

Commit 34b688f

Browse files
committed
pause validation
1 parent 20bbae8 commit 34b688f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

haxe/ui/backend/ComponentBase.hx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,10 @@ class ComponentBase extends ComponentSurface implements IClonable<ComponentBase>
13781378
return; //it should be added into the queue later
13791379
}
13801380

1381+
if (isComponentValidationPaused) {
1382+
return;
1383+
}
1384+
13811385
var isAlreadyInvalid:Bool = isComponentInvalid(flag);
13821386
var isAlreadyDelayedInvalid:Bool = false;
13831387
if (_isValidating == true) {
@@ -1568,7 +1572,35 @@ class ComponentBase extends ComponentSurface implements IClonable<ComponentBase>
15681572
}
15691573
}
15701574

1575+
private var _validationPaused:Bool = false;
1576+
public function pauseComponentValidation() {
1577+
_validationPaused = true;
1578+
}
1579+
1580+
private var isComponentValidationPaused(get, never):Bool;
1581+
private function get_isComponentValidationPaused():Bool {
1582+
var ref = this;
1583+
while (ref != null) {
1584+
if (ref._validationPaused) {
1585+
return true;
1586+
}
1587+
ref = ref.parentComponent;
1588+
}
1589+
return false;
1590+
}
1591+
1592+
public function resumeComponentValidation() {
1593+
Toolkit.callLater(() -> {
1594+
_validationPaused = false;
1595+
invalidateComponent(true);
1596+
});
1597+
}
1598+
15711599
private function validateComponentInternal(nextFrame:Bool = true) {
1600+
if (isComponentValidationPaused) {
1601+
return;
1602+
}
1603+
15721604
var dataInvalid = isComponentInvalid(InvalidationFlags.DATA);
15731605
var styleInvalid = isComponentInvalid(InvalidationFlags.STYLE);
15741606
var textDisplayInvalid = isComponentInvalid(InvalidationFlags.TEXT_DISPLAY) && hasTextDisplay();

0 commit comments

Comments
 (0)