示例#1
0
        public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction)
        {
            // passed to the current colour panel if any
            Control ctrFocused = GUIUtilities.GetFocusControl();

            (ctrFocused as ColourPanel)?.TriggerAction(this);
        }
示例#2
0
文件: KeyForm.cs 项目: stuart2w/SAW
        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;
                }
            }
        }