Exemplo n.º 1
0
        public static bool PerformKeyPress(KeyPressEvent e)
        {
            if (!active)
            {
                return(false);
            }

            if (currentString.Length < 1024)
            {
                bool allowCharacter = false;

                if (font != null)
                {
                    allowCharacter = e.KeyChar >= 32 && font.IsCharacterInitialized(e.KeyChar);
                }
                else
                {
                    allowCharacter = e.KeyChar >= 32 && e.KeyChar < 128;
                }

                if (allowCharacter)
                {
                    currentString += e.KeyChar.ToString();
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        protected override bool OnKeyPress(KeyPressEvent e)
        {
            if (Focused && EnabledInHierarchy && VisibleInHierarchy && browserHost != null)
            {
                browserHost.SendFocusEvent(true);

                try
                {
                    //_logger.Debug(string.Format("KeyDown: system key {0}, key {1}", arg.SystemKey, arg.Key));
                    CefKeyEvent keyEvent = new CefKeyEvent()
                    {
                        EventType      = CefKeyEventType.Char,
                        WindowsKeyCode = (int)e.KeyChar
                    };

                    keyEvent.Modifiers = GetCurrentKeyboardModifiers();

                    browserHost.SendKeyEvent(keyEvent);
                }
                catch (Exception ex)
                {
                    Log.Error("UIWebBrowser: Caught exception in OnKeyDown: " + ex.Message);
                }

                //arg.Handled = true;

                return(true);
            }

            return(base.OnKeyPress(e));
        }
Exemplo n.º 3
0
        //protected override bool OnKeyUp( KeyEvent e )
        //{
        //   if( PreKeyUp != null )
        //   {
        //      bool handled;
        //      PreKeyUp( e, ref handled );
        //      if( handled )
        //         return true;
        //   }

        //   return base.OnKeyUp( e );
        //}

        protected override bool OnKeyPress(KeyPressEvent e)
        {
            var textControl = GetTextControl();

            if (textControl != null)
            {
                //!!!!было
                //if( PreKeyPress != null )
                //{
                //	bool handled = false;
                //	PreKeyPress( e, ref handled );
                //	if( handled )
                //		return true;
                //}

                if (Focused && EnabledInHierarchy)
                {
                    if (Text.Value.Length < MaxCharacterCount)
                    {
                        var font = textControl.Font.Value;
                        if (font == null)
                        {
                            //!!!!!!так правильно?
                            if (ParentContainer != null && ParentContainer.Viewport.CanvasRenderer != null)
                            {
                                font = ParentContainer.Viewport.CanvasRenderer.DefaultFont;
                            }
                            //if( EngineApp.Instance.ScreenGuiRenderer != null )
                            //   font = EngineApp.Instance.ScreenGuiRenderer.DefaultFont;
                        }

                        bool allowCharacter;
                        if (font != null)
                        {
                            allowCharacter = e.KeyChar >= 32 && font.IsCharacterInitialized(e.KeyChar);
                        }
                        else
                        {
                            allowCharacter = e.KeyChar >= 32 && e.KeyChar < 128;
                        }

                        if (allowCharacter)
                        {
                            string newText = Text + e.KeyChar.ToString();
                            if (OnTextTypingFilter(0, e.KeyChar, newText))
                            {
                                Text = newText;
                            }
                            //Text += e.KeyChar.ToString();
                        }
                    }

                    return(true);
                }
            }

            return(base.OnKeyPress(e));
        }
Exemplo n.º 4
0
        public bool PerformKeyPress(KeyPressEvent e)
        {
            CheckCachedParameters();
            UpdateCachedCoverControls();

            if (capturedControl != null && capturedControl.ParentContainer == null)
            {
                capturedControl = null;
            }
            if (focusedControl != null && focusedControl.ParentContainer == null)
            {
                focusedControl = null;
            }

            if (focusedControl != null)
            {
                return(focusedControl.CallKeyPress(e));
            }

            return(CallKeyPress(e));
        }
Exemplo n.º 5
0
        private void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
        {
            var viewport = GetViewport();

            if (viewport == null)
            {
                return;
            }

            if (!GetEKeyByVirtualKey(args.VirtualKey, out EKeys eKey))
            {
                return;
            }

            if (args.EventType == CoreAcceleratorKeyEventType.KeyDown || args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown)
            {
                bool handled  = false;
                var  keyEvent = new KeyEvent(eKey);
                viewport.PerformKeyDown(keyEvent, ref handled);
                if (keyEvent.SuppressKeyPress)
                {
                    args.Handled = true;
                }

                if (!handled && EngineApp.InitSettings.AllowChangeScreenVideoMode)
                {
                    //support Alt+F4 in mouse relative mode. Alt+F4 is disabled during captured cursor.
                    if (viewport.MouseRelativeMode)
                    {
                        if (eKey == EKeys.F4 && viewport.IsKeyPressed(EKeys.Alt))
                        {
                            EngineApp.NeedExit = true;
                            return;
                        }
                    }

                    if (viewport.IsKeyPressed(EKeys.Alt) && eKey == EKeys.Return)
                    {
                        EngineApp.SetFullscreenMode(!EngineApp.FullscreenEnabled, EngineApp.FullscreenSize);
                        //App.FullScreen = !App.FullScreen;
                        handled = true;
                    }
                }

                //args.Handled = handled;
            }
            else if (args.EventType == CoreAcceleratorKeyEventType.KeyUp || args.EventType == CoreAcceleratorKeyEventType.SystemKeyUp)
            {
                bool handled = false;
                viewport.PerformKeyUp(new KeyEvent(eKey), ref handled);
                //args.Handled = handled;
            }
            else if (args.EventType == CoreAcceleratorKeyEventType.Character || args.EventType == CoreAcceleratorKeyEventType.UnicodeCharacter)
            {
                char          keyChar       = (char)args.VirtualKey;
                KeyPressEvent keyPressEvent = new KeyPressEvent(keyChar);
                bool          handled       = false;
                GetViewport()?.PerformKeyPress(keyPressEvent, ref handled);
                //args.Handled = handled;
            }
        }