protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { Keys nmKeyData = (Keys)((int)keyData & 0x0FFFF); bool preProcess = nmKeyData >= Keys.F1 && nmKeyData <= Keys.F24; preProcess = preProcess || (nmKeyData == Keys.Escape); preProcess = preProcess || (nmKeyData == Keys.Up) || (nmKeyData == Keys.Down); preProcess = preProcess || (nmKeyData == Keys.Tab) || (nmKeyData == Keys.Enter); preProcess = preProcess || keyData.HasFlag(Keys.Control) || keyData.HasFlag(Keys.Alt); // menu shortcut if (propertiesExplorer.EntryWithTextBox == null) { preProcess |= (nmKeyData == Keys.Delete); // the delete key is preferred by the textbox, if there is one } Substitutes.KeyEventArgs e = new Substitutes.KeyEventArgs((Substitutes.Keys)keyData); if (preProcess) { e.Handled = false; cadFrame.PreProcessKeyDown(e); if (e.Handled) { return(true); } } CadFrame.PreProcessKeyDown(e); if (e.Handled) { return(true); } //if (msg.Msg== 0x0101) // WM_KEYUP //{ } return(base.ProcessCmdKey(ref msg, keyData)); }
public void PreProcessKeyDown(Substitutes.KeyEventArgs e) { // this is being called after the ActiveAction has preprocessed (and not handled) the key down message // we can handle it here, before it gets handled by maybe and edit text box or something else (menu?) switch ((Substitutes.Keys)((int)e.KeyData & 0x0FFFF)) // was KeyCode, but didn't work { case Substitutes.Keys.Tab: if ((e.KeyData & Substitutes.Keys.Control) != 0) { // we use the Ctrl key to switch between property pages int sel = -1; for (int i = 0; i < tabControl.TabPages.Count; i++) { if (tabControl.TabPages[i] == tabControl.SelectedTab) { sel = i; break; } } if (sel >= 0) { if ((e.KeyData & Substitutes.Keys.Shift) != 0) { sel = (sel + tabControl.TabPages.Count - 1) % tabControl.TabPages.Count; } else { sel = (sel + 1) % tabControl.TabPages.Count; } tabControl.SelectedTab = tabControl.TabPages[sel]; } } else { if (EntryWithTextBox != null) { EntryWithTextBox.EndEdit(false, textBox.Modified, textBox.Text); HideTextBox(); } else if (EntryWithListBox != null) { EntryWithListBox.ListBoxSelected(listBox.SelectedIndex); HideListBox(); } SelectNextEntry((e.KeyData & Substitutes.Keys.Shift) == 0); } e.Handled = true; e.SuppressKeyPress = true; break; case Substitutes.Keys.Enter: if (EntryWithTextBox != null) { EntryWithTextBox.EndEdit(false, textBox.Modified, textBox.Text); HideTextBox(); } else if (EntryWithListBox != null) { EntryWithListBox.ListBoxSelected(listBox.SelectedIndex); HideListBox(); } else if (ActivePropertyPage is PropertyPage pp) { pp.OnEnter(); } e.Handled = true; break; case Substitutes.Keys.Escape: if (EntryWithTextBox != null) { EntryWithTextBox.EndEdit(true, textBox.Modified, textBox.Text); HideTextBox(); e.Handled = true; } else if (EntryWithListBox != null) { // no notification of the entry, nothing has changed until now HideListBox(); e.Handled = true; } break; case Substitutes.Keys.Down: SelectNextEntry(true); e.Handled = true; break; case Substitutes.Keys.Up: SelectNextEntry(false); e.Handled = true; break; } }