示例#1
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            TextServicesContext context;
            KeyEventArgs        keyArgs;

            if (!TextServicesLoader.ServicesInstalled)
            {
                return;
            }

            // IMM32-IME handles the key event and we don't do anything.
            if (InputMethod.IsImm32ImeCurrent())
            {
                return;
            }

            DependencyObject element = Keyboard.FocusedElement as DependencyObject;

            if ((element == null) || (bool)element.GetValue(InputMethod.IsInputMethodSuspendedProperty))
            {
                // The focus is on the element that suspending IME's input (such as menu).
                // we don't do anything.
                return;
            }

            if (e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyDownEvent ||
                e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyUpEvent)
            {
                // filter SysKey
                if (IsSysKeyDown())
                {
                    return;
                }

                keyArgs = (KeyEventArgs)e.StagingItem.Input;

                if (!keyArgs.Handled && keyArgs.Key == Key.ImeProcessed)
                {
                    context = TextServicesContext.DispatcherCurrent;

                    if (context != null)
                    {
                        if (TextServicesKeystroke(context, keyArgs, false /* test */))
                        {
                            keyArgs.Handled = true;
                        }
                    }
                }
            }
            else if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyDownEvent ||
                     e.StagingItem.Input.RoutedEvent == Keyboard.KeyUpEvent)
            {
                keyArgs = (KeyEventArgs)e.StagingItem.Input;
                if (!keyArgs.Handled && keyArgs.Key == Key.ImeProcessed)
                {
                    keyArgs.Handled = true;
                }
            }
        }
示例#2
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        internal TextServicesCompartmentEventSink(InputMethod inputmethod)
        {
            _inputmethod = inputmethod;
        }
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        internal TextServicesCompartmentEventSink(InputMethod inputmethod)
        {
            _inputmethod = inputmethod;
        }