From: NathanSweet Date: Fri, 4 Oct 2013 16:48:05 +0000 (+0200) Subject: Shortcut hit detection in WidgetGroup, since groups UI are normally sized to encompas... X-Git-Url: http://git.osdn.net/view?p=mikumikustudio%2Flibgdx-mikumikustudio.git;a=commitdiff_plain;h=f92f71656f306a60c68790f4b8f5e39432d2c59d Shortcut hit detection in WidgetGroup, since groups UI are normally sized to encompass all child actors. http://www.java-gaming.org/topics/ui-mouse-detection/30896/msg/285894/view.html#msg285894 --- diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/WidgetGroup.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/WidgetGroup.java index bb2fac6fc..79e02b968 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/WidgetGroup.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/WidgetGroup.java @@ -20,6 +20,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.utils.Layout; import com.badlogic.gdx.utils.SnapshotArray; @@ -148,4 +149,10 @@ public class WidgetGroup extends Group implements Layout { validate(); super.draw(batch, parentAlpha); } + + public Actor hit (float x, float y, boolean touchable) { + if (touchable && getTouchable() == Touchable.disabled) return null; + if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight()) return null; + return super.hit(x, y, touchable); + } }