Browse Source

Added a function, openURL, which opens an URL in the browser. (#756)

Aksel 5 years ago
parent
commit
bc7e665b3f
4 changed files with 20 additions and 0 deletions
  1. 4 0
      hxd/System.flash.hx
  2. 10 0
      hxd/System.hl.hx
  3. 2 0
      hxd/System.hx
  4. 4 0
      hxd/System.js.hx

+ 4 - 0
hxd/System.flash.hx

@@ -140,6 +140,10 @@ class System {
 			flash.system.System.exit(0);
 			flash.system.System.exit(0);
 	}
 	}
 
 
+	public static function openURL( url : String ) : Void {
+		throw 'Not implemented';
+	}
+
 	// getters
 	// getters
 
 
 	static function get_width() {
 	static function get_width() {

+ 10 - 0
hxd/System.hl.hx

@@ -295,6 +295,16 @@ class System {
 		}
 		}
 	}
 	}
 
 
+	public static function openURL( url : String ) : Void {
+		switch Sys.systemName() {
+			case 'Windows': Sys.command('start ${url}');
+			case 'Linux': Sys.command('xdg-open ${url}');
+			case 'Mac': Sys.command('open ${url}');
+			case 'Android' | 'iOS' | 'tvOS': 
+			default:
+		}
+	}
+
 	@:hlNative("std","sys_locale") static function sys_locale() : hl.Bytes { return null; }
 	@:hlNative("std","sys_locale") static function sys_locale() : hl.Bytes { return null; }
 
 
 	static var _lang : String;
 	static var _lang : String;

+ 2 - 0
hxd/System.hx

@@ -75,6 +75,8 @@ class System {
 	public static function exit() : Void {
 	public static function exit() : Void {
 	}
 	}
 
 
+	public static function openURL( url : String ) : Void {}
+
 	// getters
 	// getters
 
 
 	static function get_width() : Int return 0;
 	static function get_width() : Int return 0;

+ 4 - 0
hxd/System.js.hx

@@ -110,6 +110,10 @@ class System {
 	public static function exit() : Void {
 	public static function exit() : Void {
 	}
 	}
 
 
+	public static function openURL( url : String ) : Void {
+		js.Browser.window.open(url, '_blank');
+	}
+
 	static function updateCursor() : Void {
 	static function updateCursor() : Void {
 		if ( currentCustomCursor != null ) {
 		if ( currentCustomCursor != null ) {
 			var change = currentCustomCursor.update(hxd.Timer.elapsedTime);
 			var change = currentCustomCursor.update(hxd.Timer.elapsedTime);