Skip to content

Commit

Permalink
Unfocus children in Group#clearChildren() (#6423)
Browse files Browse the repository at this point in the history
* Add Group#clearChildren(boolean unfocus)

* CHANGES note for breaking change.

* Change clearChildren without args to unfocus.

* Typo..

Co-authored-by: Nathan Sweet <nathan.sweet@gmail.com>
  • Loading branch information
petoncle and NathanSweet committed Feb 21, 2021
1 parent 697bd90 commit 909fd8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
@@ -1,6 +1,7 @@
[1.9.15]
- [BREAKING CHANGE] Requires Java 7 or above
- [BREAKING CHANGE] API Change: Scaling is now an object instead of an enum. This may change behavior when used with serialization.
- [BREAKING CHANGE] Group#clearChildren() now unfocuses the actors. Added Group#clearChildren(boolean unfocus) for when this isn't wanted. #6423
- Scene2d.ui: Added new ParticleEffectActor to use particle effects on Stage
- API addition: iOS: Added HdpiMode option to IOSApplicationConfiguration to allow users to set whether they want to work in logical or raw pixels (default logical).
- Fix for #6377 Gdx.net.openURI not working with targetSdk 30
Expand Down
11 changes: 10 additions & 1 deletion gdx/src/com/badlogic/gdx/scenes/scene2d/Group.java
Expand Up @@ -349,11 +349,20 @@ public Actor removeActorAt (int index, boolean unfocus) {
return actor;
}

/** Removes all actors from this group. */
/** Removes all actors from this group and unfocuses them. Calls {@link #clearChildren(boolean)} with true. */
public void clearChildren () {
clearChildren(true);
}

/** Removes all actors from this group. */
public void clearChildren (boolean unfocus) {
Actor[] actors = children.begin();
for (int i = 0, n = children.size; i < n; i++) {
Actor child = actors[i];
if (unfocus) {
Stage stage = getStage();
if (stage != null) stage.unfocus(child);
}
child.setStage(null);
child.setParent(null);
}
Expand Down

0 comments on commit 909fd8a

Please sign in to comment.