/// <summary> /// Processes a command key</summary> /// <param name="msg">A <see cref="T:System.Windows.Forms.Message"></see>, passed by reference, that represents the Win32 message to process</param> /// <param name="keyData">One of the <see cref="T:System.Windows.Forms.Keys"></see> values that represents the key to process</param> /// <returns>True if the keystroke was processed and consumed by the control; otherwise false to allow further processing</returns> protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { bool consumed = false; // Route to command service if not a text input control. If it is a text input control, // only route to the command service if the keypress is not standard textbox input. Control focusedControl = WinFormsUtil.GetFocusedControl(); if ( (!(focusedControl is TextBoxBase) && !(focusedControl is ComboBox)) || !KeysUtil.IsTextBoxInput(focusedControl, keyData) ) { if (m_commandService != null) { consumed = m_commandService.ProcessKey(keyData); } // If the command key wasn't processed, then let the base handle it so that certain // default behavior like the access keys (the underlines that appear when Alt is held down) // still work correctly. if (!consumed) { consumed = base.ProcessCmdKey(ref msg, keyData); } } return(consumed); }