Browse Source

tools: reset keyboard modifiers when Level Editor window lose focus

Daniele Bartolini 5 years ago
parent
commit
b30d6bb013
1 changed files with 11 additions and 0 deletions
  1. 11 0
      tools/level_editor/level_editor.vala

+ 11 - 0
tools/level_editor/level_editor.vala

@@ -34,6 +34,7 @@ namespace Crown
 			this.show.connect(this.on_show);
 			this.delete_event.connect(this.on_delete_event);
 			this.set_default_size(WINDOW_DEFAULT_WIDTH, WINDOW_DEFAULT_HEIGHT);
+			this.focus_out_event.connect(this.on_focus_out);
 
 			_fullscreen = false;
 		}
@@ -93,6 +94,16 @@ namespace Crown
 
 			return true; // Keep alive
 		}
+
+		private bool on_focus_out(Gdk.EventFocus ev)
+		{
+			LevelEditorApplication app = (LevelEditorApplication)application;
+
+			app._editor.send_script(LevelEditorApi.key_up("ctrl_left"));
+			app._editor.send_script(LevelEditorApi.key_up("shift_left"));
+			app._editor.send_script(LevelEditorApi.key_up("alt_left"));
+			return true;
+		}
 	}
 
 	public enum ToolType