浏览代码

[hide] Added global breakpoint shortcut on Alt+F1

Clément Espeute 2 月之前
父节点
当前提交
8ef8aa9c3e
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18 0
      hide/Ide.hx

+ 18 - 0
hide/Ide.hx

@@ -46,6 +46,8 @@ class Ide extends hide.tools.IdeData {
 	var goldenContainer : hide.Element;
 	var goldenContainer : hide.Element;
 	var statusIcons : hide.Element;
 	var statusIcons : hide.Element;
 
 
+	var breakShortcut : Dynamic;
+
 	public var show3DIcons = true;
 	public var show3DIcons = true;
 	public var show3DIconsCategory : Map<hrt.impl.EditorTools.IconCategory, Bool> = new Map();
 	public var show3DIconsCategory : Map<hrt.impl.EditorTools.IconCategory, Bool> = new Map();
 
 
@@ -547,6 +549,21 @@ class Ide extends hide.tools.IdeData {
 
 
 		getOrInitTarget(Center);
 		getOrInitTarget(Center);
 
 
+		// register a global shortcut that break in the debugger
+		// on Alt+F1. Usefull to debug UI elements that are temporary
+		// Note : the debugger window must be open for this to work
+		{
+			var option = {
+				key: "Alt+F1",
+				active: () -> {
+					js.Lib.debug();
+				}
+			};
+
+			breakShortcut = js.Syntax.construct("nw.Shortcut", option);
+			untyped nw.App.registerGlobalHotKey(breakShortcut);
+		}
+
 		var waitCount = 0;
 		var waitCount = 0;
 		function waitInit() {
 		function waitInit() {
 			waitCount++;
 			waitCount++;
@@ -909,6 +926,7 @@ class Ide extends hide.tools.IdeData {
 	public function reload() {
 	public function reload() {
 		hasReloaded = true;
 		hasReloaded = true;
 		fileWatcher.dispose();
 		fileWatcher.dispose();
+		untyped nw.App.unregisterGlobalHotKey(breakShortcut);
 		hide.tools.FileManager.onBeforeReload();
 		hide.tools.FileManager.onBeforeReload();
 		hide.view.RemoteConsoleView.onBeforeReload();
 		hide.view.RemoteConsoleView.onBeforeReload();
 		js.Browser.location.reload();
 		js.Browser.location.reload();