Browse Source

changed Interactive.blockEvents to cancelEvents, added a bit of documentation

ncannasse 11 years ago
parent
commit
590e17de5f
3 changed files with 15 additions and 3 deletions
  1. 8 2
      h2d/Interactive.hx
  2. 1 1
      h2d/comp/Slider.hx
  3. 6 0
      hxd/Event.hx

+ 8 - 2
h2d/Interactive.hx

@@ -6,7 +6,13 @@ class Interactive extends Drawable {
 	public var height : Float;
 	public var cursor(default,set) : hxd.System.Cursor;
 	public var isEllipse : Bool;
-	public var blockEvents : Bool = true;
+	/**
+		Set the default `cancel` mode (see `hxd.Event`), default to false.
+	**/
+	public var cancelEvents : Bool = false;
+	/**
+		Set the default `propagate` mode (see `hxd.Event`), default to false.
+	**/
 	public var propagateEvents : Bool = false;
 	public var backgroundColor : Null<Int>;
 	public var enableRightButton : Bool;
@@ -79,7 +85,7 @@ class Interactive extends Drawable {
 			}
 		}
 		if( propagateEvents ) e.propagate = true;
-		if( !blockEvents ) e.cancel = true;
+		if( cancelEvents ) e.cancel = true;
 		switch( e.kind ) {
 		case EMove:
 			onMove(e);

+ 1 - 1
h2d/comp/Slider.hx

@@ -12,7 +12,7 @@ class Slider extends Component {
 	public function new(?parent) {
 		super("slider", parent);
 		cursor = new Button("", this);
-		cursor.input.blockEvents = false;
+		cursor.input.cancelEvents = true;
 		cursor.onMouseDown = function() {
 			
 		};

+ 6 - 0
hxd/Event.hx

@@ -18,7 +18,13 @@ class Event {
 	public var kind : EventKind;
 	public var relX : Float;
 	public var relY : Float;
+	/**
+		Will propagate the event to other interactives that are below the current one.
+	**/
 	public var propagate : Bool;
+	/**
+		Will cancel the default behavior for this event as if it had happen outside of the interactive zone.
+	**/
 	public var cancel : Bool;
 	public var button : Int;
 	public var touchId : Int;