OSDN Git Service

DragAndDrop, disallow stage root as target.
authorNathanSweet <nathan.sweet@gmail.com>
Mon, 7 Jan 2013 10:21:19 +0000 (11:21 +0100)
committerNathanSweet <nathan.sweet@gmail.com>
Mon, 7 Jan 2013 10:21:19 +0000 (11:21 +0100)
gdx/src/com/badlogic/gdx/scenes/scene2d/utils/DragAndDrop.java

index 9628db2..d3dbf77 100644 (file)
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  ******************************************************************************/
+
 package com.badlogic.gdx.scenes.scene2d.utils;
 
 import com.badlogic.gdx.Input.Buttons;
@@ -183,6 +184,9 @@ public class DragAndDrop {
                public Target (Actor actor) {
                        if (actor == null) throw new IllegalArgumentException("actor cannot be null.");
                        this.actor = actor;
+                       Stage stage = actor.getStage();
+                       if (stage != null && actor == stage.getRoot())
+                               throw new IllegalArgumentException("The stage root cannot be a drag and drop target.");
                }
 
                /** Called when the object is dragged over the target. The coordinates are in the target's local coordinate system.
@@ -238,4 +242,4 @@ public class DragAndDrop {
                        this.object = object;
                }
        }
-}
\ No newline at end of file
+}