コード例 #1
0
        public void IMEKeyboard_SetNoKeyboard_DisablesKeyboard()
        {
            using (var switcher = new KeyboardSwitcher())
            {
                // Create an input context
                using (var controller = new DummyInputBusController())
                {
                    controller.Focus();
                    var context = GlobalCachedInputContext.InputContext;

                    // Set input method using the first available keyboard
                    if (switcher.IMEKeyboardsCount <= 0)
                    {
                        Console.WriteLine("Warning: Test IMEKeyboard_SetNoKeyboard_DisablesKeyboard unable to run since no iBus keyboards available or no iBus running.");
                        return;                 // Can't test without an iBus engine to use.
                    }
                    switcher.IMEKeyboard = switcher.GetKeyboardName(0);
                    Assert.That(context.IsEnabled(), Is.True, "Keyboard input method should be enabled when set");

                    // Turn off input method
                    switcher.IMEKeyboard = null;
                    Assert.That(context.IsEnabled(), Is.False, "Should have disabled keyboard input method");
                }
            }
        }
コード例 #2
0
        private void InitKeyboards()
        {
            var nKeyboards = m_KeyboardSwitcher.IMEKeyboardsCount;

            for (int i = 0; i < nKeyboards; i++)
            {
                var name     = m_KeyboardSwitcher.GetKeyboardName(i);
                var id       = name.GetHashCode();
                var keyboard = new KeyboardDescription(id, name, this, KeyboardType.OtherIm);
                KeyboardController.Manager.RegisterKeyboard(id, keyboard);
            }
        }