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();
iconsmgr = new ScriptIconsManager(scripticons); //mxd
tabs.ImageList = scripticons; //mxd
PreviewKeyDown += new PreviewKeyDownEventHandler(ScriptEditorPanel_PreviewKeyDown);
KeyDown += new KeyEventHandler(ScriptEditorPanel_KeyDown);
}
// This initializes the control
@ -830,6 +832,9 @@ namespace CodeImp.DoomBuilder.Controls
// This updates the toolbar for the current status
private void UpdateInterface(bool focuseditor)
{
menustrip.Enabled = false;
menustrip.Enabled = true;
int numscriptsopen = tabs.TabPages.Count;
int explicitsavescripts = 0;
ScriptDocumentTab t = null;
@ -1072,6 +1077,21 @@ namespace CodeImp.DoomBuilder.Controls
#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
public void OnClose()
{

View file

@ -282,6 +282,9 @@ namespace CodeImp.DoomBuilder.Windows
//mxd. Hints
hintsPanel = new HintsPanel();
hintsDocker = new Docker("hints", "Help", hintsPanel);
KeyPreview = true;
PreviewKeyDown += new PreviewKeyDownEventHandler(MainForm_PreviewKeyDown);
}
#endregion
@ -1368,6 +1371,12 @@ namespace CodeImp.DoomBuilder.Windows
// base? what base?
}
private void MainForm_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.F10)
e.IsInputKey = true;
}
// When a key is pressed
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

View file

@ -46,6 +46,9 @@ namespace CodeImp.DoomBuilder.Windows
{
InitializeComponent();
editor.Initialize(this);
KeyPreview = true;
PreviewKeyDown += new PreviewKeyDownEventHandler(ScriptEditorForm_PreviewKeyDown);
KeyDown += new KeyEventHandler(ScriptEditorForm_KeyDown);
}
#endregion
@ -87,6 +90,21 @@ namespace CodeImp.DoomBuilder.Windows
#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
private void ScriptEditorForm_Load(object sender, EventArgs e)
{