فهرست منبع

added Callback special cursor

ncannasse 6 سال پیش
والد
کامیت
cf8cc8ec53
5فایلهای تغییر یافته به همراه12 افزوده شده و 3 حذف شده
  1. 4 0
      hxd/Cursor.hx
  2. 4 1
      hxd/SceneEvents.hx
  3. 1 0
      hxd/System.flash.hx
  4. 2 2
      hxd/System.hl.hx
  5. 1 0
      hxd/System.js.hx

+ 4 - 0
hxd/Cursor.hx

@@ -7,6 +7,10 @@ enum Cursor {
 	TextInput;
 	Hide;
 	Custom( custom : CustomCursor );
+	/**
+		When this cursor is selected, call the function itself, which can handle complex logic and is responsible to call hxd.System.setCursor
+	**/
+	Callback( f : Void -> Void );
 }
 
 @:allow(hxd.System)

+ 4 - 1
hxd/SceneEvents.hx

@@ -370,7 +370,10 @@ class SceneEvents {
 				break;
 			}
 		}
-		hxd.System.setCursor(cur);
+		switch( cur ) {
+		case Callback(f): f();
+		default: hxd.System.setCursor(cur);
+		}
 	}
 
 	function onEvent( e : hxd.Event ) {

+ 1 - 0
hxd/System.flash.hx

@@ -78,6 +78,7 @@ class System {
 				flash.ui.Mouse.registerCursor(cursor.name, cursor.alloc);
 			}
 			cursor.name;
+		case Callback(_): throw "assert";
 		}
 		if( c == Hide ) flash.ui.Mouse.hide() else flash.ui.Mouse.show();
 	}

+ 2 - 2
hxd/System.hl.hx

@@ -136,7 +136,7 @@ class System {
 		}
 		Sys.exit(0);
 	}
-	
+
 	#if hot_reload
 	@:hlNative("std","sys_check_reload")
 	static function check_reload() return false;
@@ -197,7 +197,7 @@ class System {
 			cur = Cursor.createSystem(SizeALL);
 		case TextInput:
 			cur = Cursor.createSystem(IBeam);
-		case Hide:
+		case Callback(_), Hide:
 			throw "assert";
 		case Custom(c):
 			if( c.alloc == null ) {

+ 1 - 0
hxd/System.js.hx

@@ -73,6 +73,7 @@ class System {
 			case Move: "move";
 			case TextInput: "text";
 			case Hide: "none";
+			case Callback(_): throw "assert";
 			case Custom(cur):
 				if ( cur.alloc == null ) {
 					cur.alloc = new Array();