Пример #1
0
        public void txtKey_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.ShiftKey:
            case Keys.LMenu:
            case Keys.ControlKey:
            case Keys.RMenu:
            case Keys.RShiftKey:
            case Keys.RWin:
            case Keys.LWin:
            case Keys.LControlKey:
            case Keys.RControlKey:
                break;

            case Keys.RButton:
            case Keys.Menu:
                break;

            default:
                CombinedKeyEvent combined = new CombinedKeyEvent(e);                         // on Mac this will modify the key as needed
                DisplayKey(combined.KeyData);
                m_KeyIsChanged = true;
                break;
            }
            e.SuppressKeyPress = true;
            e.Handled          = true;
        }
Пример #2
0
        public void txtKey_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.ShiftKey:
            case Keys.LMenu:
            case Keys.ControlKey:
            case Keys.RMenu:
            case Keys.RShiftKey:
            case Keys.RWin:
            case Keys.LWin:
            case Keys.LControlKey:
            case Keys.RControlKey:
                break;

            case Keys.RButton:
            case Keys.Menu:
                break;

            default:
                m_eKey = e.KeyData;
                CombinedKeyEvent eCombined = new CombinedKeyEvent(e);                         // on Mac this will modify the key as needed
                txtKey.Text = GUIUtilities.KeyDescription(eCombined.KeyData);
                break;
            }
            e.Handled          = true;
            e.SuppressKeyPress = false;
            if (ctrActions.SelectedAction.Change == Parameters.Action_Key || ctrActions.SelectedAction.Change == Parameters.Action_Character)
            {
                btnAdd.Enabled = true;
            }
        }
Пример #3
0
 internal void KeyForm_KeyDown(object sender, KeyEventArgs e)
 {
     e.Handled = true;
     // KeyCode is the pure key. KeyData includes modifiers
     m_LastDown    = e;
     m_PendingDown = e;
     // Mac conversion of Key done by constructing New CombinedKeyEvent from the event
     if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Home || e.KeyCode == Keys.End || e.KeyCode == Keys.PageDown || e.KeyCode == Keys.PageUp || e.KeyCode == Keys.Insert || e.KeyCode >= Keys.F1 && e.KeyCode <= Keys.F24 || e.KeyCode == Keys.Delete || e.KeyCode == Keys.Pause || e.KeyCode == Keys.Apps)             //, Keys.ShiftKey, Keys.ControlKey, Keys.Menu
     {
         // none of these generate KeyPress
         CombinedKeyEvent objEvent = new CombinedKeyEvent(e);                 // Character defaults to Null
         SendCombinedKeyEvent(objEvent, true);
         // We do need some of these keys to be returned to Windows with e.Handle = false (e.g. Alt-F4)
         e.Handled = objEvent.Handled;
     }
     else
     {
         if (e.Alt ^ e.Control || e.Alt && e.Control && e.Shift)                 // Xor because ctrl+Alt is AltGr which is used for key combos; so this should be treated as a character key not a combo
         {
             // but... now allowing all 3 keys to go here.  I don't think any character uses shift with ctrl+Alt
             CombinedKeyEvent objCustom = new CombinedKeyEvent(e);
             SendCombinedKeyEvent(objCustom, true);
             // some control combinations seem to send press events, and not others
             if (objCustom.Handled && e.Alt)
             {
                 e.SuppressKeyPress = true;                         // must stop menu activating with Alt+key combinations which did something
             }
         }
     }
 }
Пример #4
0
 public void CombinedKeyDown(CombinedKeyEvent e)
 {
     //if ((((e.KeyCode == System.Windows.Forms.Keys.Right) || (e.KeyCode == System.Windows.Forms.Keys.Left)) || (e.KeyCode == System.Windows.Forms.Keys.Up)) || (e.KeyCode == System.Windows.Forms.Keys.Down))
     //{
     //}
     //else if ((e.KeyCode == System.Windows.Forms.Keys.Tab) || (e.KeyCode == (System.Windows.Forms.Keys.Tab | System.Windows.Forms.Keys.Shift)))
     //{
     //}
 }
Пример #5
0
        protected virtual void SendCombinedKeyEvent(CombinedKeyEvent e, bool down)
        {
            // note e may not be the event sent by Windows; so changing Handled or SuppressKeyPress won't always do much
            // IF DOWN KEYS AREN'T ARRIVING FOR SPECIAL KEYS (cursors, etc) - check that controls all implement IsInputKey for relevant keys
            Control current = GUIUtilities.GetFocusControl();

            //if (current is TextBoxAllKeys)
            //{
            //	e.Handled = false;
            //	return;
            //}
            m_PendingDown = null;
#if DEBUG
            if (down)
            {
                //Debug.WriteLine(IIf(e.Alt, "Alt-", "") + IIf(e.Shift, "Sh-", "") + IIf(e.Control, "Ctrl-", "") + e.KeyCode.ToString + "=" + CInt(e.KeyCode).ToString + " with " + IIf(CurrentFocus Is Nothing, " no focus", "focus in "+curr))
                //If Not CurrentFocus Is Nothing Then Debug.WriteLine("CurrentFocus = " + CurrentFocus.GetType.Name)
                //If Not GetFocusControlFromWindows() Is Nothing Then Debug.WriteLine("CurrentFocusFromWindows = " + GetFocusControlFromWindows.GetType.Name)
            }
#endif
            while (current != null && e.Handled == false)
            {
                if (e.DoNotHandle)                // shouldn't really be set on first pass, but just in case
                {
                    return;
                }
                if (current is IKeyControl control)
                {
                    if (down)
                    {
                        control.CombinedKeyDown(e);
                    }
                    else
                    {
                        control.CombinedKeyUp(e);
                    }
                }
                else if (current is Button button)
                {
                    if (down && e.KeyCode == Keys.Space)
                    {
                        button.PerformClick();
                        e.Handled = true;
                    }
                }
                if (current.Parent == null && current is Form form)
                {
                    // .Parent doesn't follow form ownership - doing this ensures that we end up back here, which is essential for misc control keys to work
                    current = form.Owner;
                }
                else
                {
                    current = current.Parent;
                }
            }
        }
Пример #6
0
 public void CombinedKeyDown(CombinedKeyEvent e)
 {
     switch (e.KeyCode)
     {
     case Keys.Apps:
         ((frmMain)Parent.Parent).ShowPaletteMenu(this, new Point(10, TITLEHEIGHT), Palette);
         e.Handled = true;
         break;
     }
 }
Пример #7
0
        public void CombinedKeyDown(CombinedKeyEvent e)
        {
            if (UseArrowKeys)
            {
                switch (e.KeyCode)
                {
                case Keys.Left:
                    Iterate(-1);
                    Accessed?.Invoke(this, EventArgs.Empty);
                    e.Handled = true;
                    break;

                case Keys.Right:
                    Iterate(1);
                    Accessed?.Invoke(this, EventArgs.Empty);
                    e.Handled = true;
                    break;

                case Keys.Up:
                    Iterate(-m_Columns);
                    Accessed?.Invoke(this, EventArgs.Empty);
                    e.Handled = true;
                    break;

                case Keys.Down:
                    Iterate(m_Columns);
                    Accessed?.Invoke(this, EventArgs.Empty);
                    e.Handled = true;
                    break;
                }
            }
            if (e.KeyData == Keys.Tab)
            {
                if (!Iterate(1, false))
                {
                    GUIUtilities.IterateTabStop(this.Parent, true);
                }
                Accessed?.Invoke(this, EventArgs.Empty);
                e.Handled = true;
            }
            else if (e.KeyData == (Keys.Tab | Keys.Shift))
            {
                if (!Iterate(-1, false))
                {
                    GUIUtilities.IterateTabStop(this.Parent, false);
                }
                Accessed?.Invoke(this, EventArgs.Empty);
                e.Handled = true;
            }
        }
Пример #8
0
 //functions are all Friend so popup forms can send here if they receive the keys instead
 internal void KeyForm_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.Handled = true;
     if (m_PendingDown == null)
     {
         Debug.Assert(m_LastDown != null && m_LastDown.Control, "frmMain_KeyPress without KeyDown");
         // control combos all act on the KeyDown - some (rather unpredictably) do send the Press
     }
     else
     {
         CombinedKeyEvent eCombined = new CombinedKeyEvent(m_PendingDown);
         eCombined.Character = e.KeyChar;
         SendCombinedKeyEvent(eCombined, true);
         e.Handled = eCombined.Handled;
     }
 }
Пример #9
0
 public void CombinedKeyDown(CombinedKeyEvent e)
 {
     if (!Enabled || !m_Applicable)
     {
         return;
     }
     if (e.KeyData == Keys.Right || e.KeyData == Keys.Tab)
     {
         Iterate(1);
         e.Handled = true;
     }
     else if (e.KeyData == Keys.Left || e.KeyData == (Keys.Tab | Keys.Shift))
     {
         Iterate(-1);
         e.Handled = true;
     }
     else if (e.KeyData == Keys.Up)
     {
         if (IndexOf(CurrentColour, true) >= m_Columns)
         {
             Iterate(-m_Columns);
         }
         e.Handled = true;
     }
     else if (e.KeyData == Keys.Down)
     {
         if (IndexOf(CurrentColour, true) < m_Colours.Count - m_Columns)
         {
             Iterate(m_Columns);
         }
         e.Handled = true;
     }
     else if (e.KeyData == Keys.Enter || e.KeyData == Keys.Return)
     {
         if (Focused)
         {
             Globals.Root.PerformAction(Verb.Find(Codes.RestoreFocus));
             e.Handled = true;
         }
     }
 }
Пример #10
0
        public void CombinedKeyDown(CombinedKeyEvent e)
        {
            switch (e.KeyCode)
            {
            case Keys.Enter:                     // Return has same value
                Trigger();
                e.Handled = true;
                if (this.Focused)
                {
                    Globals.Root.PerformAction(Verb.Find(Codes.RestoreFocus));                             // Main set within palettes, when a selection is made the focus then restored to the typing area
                }
                break;

            case Keys.Left:
            case Keys.Right:
            case Keys.Up:
            case Keys.Down:
                (Parent as ButtonPanel)?.CombinedKeyDown(e);
                break;
            }
        }
Пример #11
0
        public void CombinedKeyDown(CombinedKeyEvent e)
        {
            if (IsResizing)
            {
                switch (e.KeyCode)
                {
                case Keys.Space:
                    EndResize(true);
                    e.Handled = true;
                    break;

                case Keys.Escape:
                    EndResize(false);
                    e.Handled = true;
                    break;
                }
            }
            else if (e.KeyCode == Keys.Apps)
            {
                // not available while resizing.  Could be outside if, but really seems a bad idea when resizing
                ((frmMain)Owner).ShowPaletteMenu(this, new Point(10, Accordion.TITLEHEIGHT), m_Palette);
                e.Handled = true;
            }
        }
Пример #12
0
 public void CombinedKeyUp(CombinedKeyEvent e)
 {
 }
Пример #13
0
 public void CombinedKeyUp(CombinedKeyEvent e)
 {
     e.DoNotHandle = true;
 }
Пример #14
0
        public void txtActionKey_KeyDown(object sender, KeyEventArgs e)
        {
            if (m_Action.Change == Parameters.Action_Character)
            {
                if (e.KeyData == Keys.Back)
                {
                }
                else if (e.KeyData == Keys.Delete)
                {
                    txtActionKey.Text  = "";
                    m_Action           = new CharAction((char)0);
                    e.SuppressKeyPress = true;
                    e.Handled          = true;
                }
                else if (e.KeyData == (Keys.V | Keys.Control))
                {
                    if (Clipboard.ContainsText())
                    {
                        var strText = Clipboard.GetText();
                        if (!string.IsNullOrEmpty(strText))
                        {
                            txtActionKey.Text  = strText.Substring(0, 1);
                            m_Action           = new CharAction(strText[0]);
                            e.SuppressKeyPress = true;
                            e.Handled          = true;
                        }
                    }
                }
            }
            if (m_Action.Change != Parameters.Action_Key)
            {
                return;
            }
            switch (e.KeyCode)
            {
            case Keys.ShiftKey:
            case Keys.LMenu:
            case Keys.ControlKey:
            case Keys.RMenu:
            case Keys.RShiftKey:
            case Keys.RWin:
            case Keys.LWin:
            case Keys.LControlKey:
            case Keys.RControlKey:
                break;

            case Keys.RButton:
            case Keys.Menu:
                break;

            default:
                m_Filling = true;
                CombinedKeyEvent eCombined = new CombinedKeyEvent(e);                         // on Mac this will modify the key as needed
                txtActionKey.Text = GUIUtilities.KeyDescription(eCombined.KeyData);
                m_Action          = new KeyAction(eCombined.KeyData);
                if (chkActionKeyAuto.Checked)
                {
                    // update the text
                    txtText.Text = eCombined.KeyData.ToCharacter().ToString();
                }
                m_Filling = false;
                break;
            }
            e.SuppressKeyPress = true;
            e.Handled          = true;
        }