v0.9.2: improved logic for buttons inside of scroll areas
This commit is contained in:
@@ -30,9 +30,11 @@ public class PointerArea extends Visual implements Signal.Listener<PointerEvent>
|
||||
public Visual target;
|
||||
|
||||
protected PointerEvent curEvent = null;
|
||||
|
||||
//if true, this PointerArea will always block input, even when it is inactive
|
||||
public boolean blockWhenInactive = false;
|
||||
|
||||
public int blockLevel = BLOCK_WHEN_ACTIVE;
|
||||
public static final int ALWAYS_BLOCK = 0; //Always block input to overlapping elements
|
||||
public static final int BLOCK_WHEN_ACTIVE = 1; //Only block when active (default)
|
||||
public static final int NEVER_BLOCK = 2; //Never block (handy for buttons in scroll areas)
|
||||
|
||||
public PointerArea( Visual target ) {
|
||||
super( 0, 0, 0, 0 );
|
||||
@@ -56,7 +58,7 @@ public class PointerArea extends Visual implements Signal.Listener<PointerEvent>
|
||||
boolean hit = event != null && target.overlapsScreenPoint( (int)event.current.x, (int)event.current.y );
|
||||
|
||||
if (!isActive()) {
|
||||
return (hit && blockWhenInactive);
|
||||
return (hit && blockLevel == ALWAYS_BLOCK);
|
||||
}
|
||||
|
||||
if (hit) {
|
||||
@@ -81,7 +83,7 @@ public class PointerArea extends Visual implements Signal.Listener<PointerEvent>
|
||||
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
return returnValue && blockLevel != NEVER_BLOCK;
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ScrollArea extends PointerArea {
|
||||
boolean hit = event != null && target.overlapsScreenPoint( (int)event.pos.x, (int)event.pos.y );
|
||||
|
||||
if (!isActive()) {
|
||||
return (hit && blockWhenInactive);
|
||||
return (hit && blockLevel == ALWAYS_BLOCK);
|
||||
}
|
||||
|
||||
if (hit){
|
||||
|
||||
@@ -261,6 +261,7 @@ public class Visual extends Gizmo {
|
||||
Camera c = camera();
|
||||
|
||||
if (c == null) return false;
|
||||
if (!c.hitTest(x, y)) return false;
|
||||
|
||||
PointF p = c.screenToCamera( x, y );
|
||||
return overlapsPoint( p.x, p.y );
|
||||
|
||||
Reference in New Issue
Block a user