Fixed F10 key focusing the menu instead of opening the script editor as intended

This commit is contained in:
ZZYZX 2019-12-31 14:57:29 +02:00
parent e092235262
commit c00e2a8074
3 changed files with 63 additions and 6 deletions

View file

@ -87,6 +87,8 @@ namespace CodeImp.DoomBuilder.Controls
InitializeComponent(); InitializeComponent();
iconsmgr = new ScriptIconsManager(scripticons); //mxd iconsmgr = new ScriptIconsManager(scripticons); //mxd
tabs.ImageList = scripticons; //mxd tabs.ImageList = scripticons; //mxd
PreviewKeyDown += new PreviewKeyDownEventHandler(ScriptEditorPanel_PreviewKeyDown);
KeyDown += new KeyEventHandler(ScriptEditorPanel_KeyDown);
} }
// This initializes the control // This initializes the control
@ -830,6 +832,9 @@ namespace CodeImp.DoomBuilder.Controls
// This updates the toolbar for the current status // This updates the toolbar for the current status
private void UpdateInterface(bool focuseditor) private void UpdateInterface(bool focuseditor)
{ {
menustrip.Enabled = false;
menustrip.Enabled = true;
int numscriptsopen = tabs.TabPages.Count; int numscriptsopen = tabs.TabPages.Count;
int explicitsavescripts = 0; int explicitsavescripts = 0;
ScriptDocumentTab t = null; ScriptDocumentTab t = null;
@ -1067,11 +1072,26 @@ namespace CodeImp.DoomBuilder.Controls
throw new NotImplementedException("Unsupported Script Status Type!"); throw new NotImplementedException("Unsupported Script Status Type!");
} }
} }
#endregion #endregion
#region ================== Events #region ================== Events
private void ScriptEditorPanel_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.F10)
e.IsInputKey = true;
}
private void ScriptEditorPanel_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F10)
{
e.SuppressKeyPress = true;
e.Handled = true;
}
}
// Called when the window that contains this panel closes // Called when the window that contains this panel closes
public void OnClose() public void OnClose()
{ {

View file

@ -282,6 +282,9 @@ namespace CodeImp.DoomBuilder.Windows
//mxd. Hints //mxd. Hints
hintsPanel = new HintsPanel(); hintsPanel = new HintsPanel();
hintsDocker = new Docker("hints", "Help", hintsPanel); hintsDocker = new Docker("hints", "Help", hintsPanel);
KeyPreview = true;
PreviewKeyDown += new PreviewKeyDownEventHandler(MainForm_PreviewKeyDown);
} }
#endregion #endregion
@ -1368,6 +1371,12 @@ namespace CodeImp.DoomBuilder.Windows
// base? what base? // base? what base?
} }
private void MainForm_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.F10)
e.IsInputKey = true;
}
// When a key is pressed // When a key is pressed
private void MainForm_KeyDown(object sender, KeyEventArgs e) private void MainForm_KeyDown(object sender, KeyEventArgs e)
{ {
@ -1420,6 +1429,16 @@ namespace CodeImp.DoomBuilder.Windows
} }
} }
} }
if (e.KeyCode == Keys.F10)
{
Actions.Action[] f10actions = General.Actions.GetActionsByKey((int)e.KeyData);
if (f10actions.Length > 0)
{
e.SuppressKeyPress = true;
e.Handled = true;
}
}
} }
// When a key is released // When a key is released

View file

@ -46,12 +46,15 @@ namespace CodeImp.DoomBuilder.Windows
{ {
InitializeComponent(); InitializeComponent();
editor.Initialize(this); editor.Initialize(this);
KeyPreview = true;
PreviewKeyDown += new PreviewKeyDownEventHandler(ScriptEditorForm_PreviewKeyDown);
KeyDown += new KeyEventHandler(ScriptEditorForm_KeyDown);
} }
#endregion #endregion
#region ================== Methods #region ================== Methods
// This asks to save files and returns the result // This asks to save files and returns the result
// Also does implicit saves // Also does implicit saves
// Returns false when cancelled by the user // Returns false when cancelled by the user
@ -84,9 +87,24 @@ namespace CodeImp.DoomBuilder.Windows
}*/ }*/
#endregion #endregion
#region ================== Events #region ================== Events
private void ScriptEditorForm_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.F10)
e.IsInputKey = true;
}
private void ScriptEditorForm_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F10)
{
e.SuppressKeyPress = true;
e.Handled = true;
}
}
// Window is loaded // Window is loaded
private void ScriptEditorForm_Load(object sender, EventArgs e) private void ScriptEditorForm_Load(object sender, EventArgs e)
{ {