diff --git a/Source/Core/Controls/DockersControl.cs b/Source/Core/Controls/DockersControl.cs index aabb0a15..74c41424 100644 --- a/Source/Core/Controls/DockersControl.cs +++ b/Source/Core/Controls/DockersControl.cs @@ -77,6 +77,19 @@ namespace CodeImp.DoomBuilder.Controls public bool IsCollpased { get { return iscollapsed; } } + // This returns true when the focus is here, but not in some special cases + public bool IsFocused + { + get + { + Control ac = FindActiveControl(); + + // We have focus when we need the keyboard for input + // Otherwise we don't want the focus and the docker may collapse + return (ac is TextBox) || (ac is RichTextBox) || (ac is NumericUpDown); + } + } + #endregion #region ================== Constructor @@ -92,6 +105,23 @@ namespace CodeImp.DoomBuilder.Controls #region ================== Methods + // This returns the active child control + private Control FindActiveControl() + { + Control c = this.ActiveControl; + + while(c is IContainerControl) + { + IContainerControl cc = (c as IContainerControl); + if(cc.ActiveControl != null) + c = cc.ActiveControl; + else + break; + } + + return c; + } + // This sets up the controls for left or right alignment public void Setup(bool right) { @@ -299,7 +329,6 @@ namespace CodeImp.DoomBuilder.Controls private void tabs_Enter(object sender, EventArgs e) { General.MainWindow.FocusDisplay(); } private void tabs_MouseUp(object sender, MouseEventArgs e) { General.MainWindow.FocusDisplay(); } private void tabs_Selected(object sender, TabControlEventArgs e) { General.MainWindow.FocusDisplay(); } - protected override void OnEnter(EventArgs e) { General.MainWindow.FocusDisplay(); } // Tab selected private void tabs_SelectedIndexChanged(object sender, EventArgs e) diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs index f1c413d6..b0717b96 100644 --- a/Source/Core/Windows/MainForm.cs +++ b/Source/Core/Windows/MainForm.cs @@ -2585,12 +2585,15 @@ namespace CodeImp.DoomBuilder.Windows { if(General.Settings.CollapseDockers) { - Point p = this.PointToClient(Cursor.Position); - Rectangle r = new Rectangle(dockerspanel.Location, dockerspanel.Size); - if(!r.IntersectsWith(new Rectangle(p, Size.Empty))) + if(!dockerspanel.IsFocused) { - dockerspanel.Collapse(); - dockerscollapser.Stop(); + Point p = this.PointToClient(Cursor.Position); + Rectangle r = new Rectangle(dockerspanel.Location, dockerspanel.Size); + if(!r.IntersectsWith(new Rectangle(p, Size.Empty))) + { + dockerspanel.Collapse(); + dockerscollapser.Stop(); + } } } else