Browse Source

prevent onClick if onPush was canceled

Nicolas Cannasse 4 years ago
parent
commit
f5ff449c60
2 changed files with 4 additions and 2 deletions
  1. 3 2
      h2d/Interactive.hx
  2. 1 0
      h3d/scene/Interactive.hx

+ 3 - 2
h2d/Interactive.hx

@@ -187,6 +187,7 @@ class Interactive extends Drawable implements hxd.SceneEvents.Interactive {
 			if( enableRightButton || e.button == 0 ) {
 			if( enableRightButton || e.button == 0 ) {
 				mouseDownButton = e.button;
 				mouseDownButton = e.button;
 				onPush(e);
 				onPush(e);
+				if( e.cancel ) mouseDownButton = -1;
 			}
 			}
 		case ERelease:
 		case ERelease:
 			if( enableRightButton || e.button == 0 ) {
 			if( enableRightButton || e.button == 0 ) {
@@ -337,9 +338,9 @@ class Interactive extends Drawable implements hxd.SceneEvents.Interactive {
 		Sent when Interactive is unpressed under multiple circumstances.
 		Sent when Interactive is unpressed under multiple circumstances.
 		* Always sent if user releases mouse while it is inside Interactive hitbox area.
 		* Always sent if user releases mouse while it is inside Interactive hitbox area.
 			This happens regardless if that Interactive was pressed prior or not,
 			This happens regardless if that Interactive was pressed prior or not,
-			and due to that it's not guaranteed that `Interactive.onPush` would precede this event.  
+			and due to that it's not guaranteed that `Interactive.onPush` would precede this event.
 			`Event.kind` is set to `ERelease` during this event.
 			`Event.kind` is set to `ERelease` during this event.
-		* Sent before `Interactive.onReleaseOutside` if this Interactive was pressed, but released outside its hitbox area.  
+		* Sent before `Interactive.onReleaseOutside` if this Interactive was pressed, but released outside its hitbox area.
 			`Event.kind` is set to `EReleaseOutside` during this event.
 			`Event.kind` is set to `EReleaseOutside` during this event.
 
 
 		See `Interactive.onClick` and `Interactive.onReleaseOutside` methods for separate events that trigger only when user interacts with this particular Interactive.
 		See `Interactive.onClick` and `Interactive.onReleaseOutside` methods for separate events that trigger only when user interacts with this particular Interactive.

+ 1 - 0
h3d/scene/Interactive.hx

@@ -77,6 +77,7 @@ class Interactive extends Object implements hxd.SceneEvents.Interactive {
 			if( enableRightButton || e.button == 0 ) {
 			if( enableRightButton || e.button == 0 ) {
 				mouseDownButton = e.button;
 				mouseDownButton = e.button;
 				onPush(e);
 				onPush(e);
+				if( e.cancel ) mouseDownButton = -1;
 			}
 			}
 		case ERelease:
 		case ERelease:
 			if( enableRightButton || e.button == 0 ) {
 			if( enableRightButton || e.button == 0 ) {