示例#1
0
        private int on_key_event(cef_keyboard_handler_t *self, cef_browser_t *browser, cef_key_event_t * @event, IntPtr os_event)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_event   = CefKeyEvent.FromNative(@event);
            // TODO: wrap cef_event_handle_t (os_event)
            IntPtr m_os_event = IntPtr.Zero;

            if (os_event != IntPtr.Zero)
            {
            }

            var result = OnKeyEvent(m_browser, m_event, m_os_event);

            return(result ? 1 : 0);
        }
示例#2
0
 /// <summary>
 /// Send a key event to the browser.
 /// </summary>
 public void SendKeyEvent(CefKeyEvent keyEvent)
 {
     if (keyEvent == null)
         throw new ArgumentNullException("keyEvent"); }
示例#3
0
        /// <summary>
        /// Send a key event to the browser.
        /// </summary>
        public void SendKeyEvent(CefKeyEvent keyEvent)
        {
            if (keyEvent == null) throw new ArgumentNullException("keyEvent");

            var n_event = new cef_key_event_t();
            keyEvent.ToNative(&n_event);
            cef_browser_host_t.send_key_event(_self, &n_event);
        }
示例#4
0
        private void OnKeyEvent(ref Message m)
        {
            var keyEvent = new CefKeyEvent();
            keyEvent.WindowsKeyCode = m.WParam.ToInt32();
            keyEvent.NativeKeyCode = (int)m.LParam.ToInt64();
            keyEvent.IsSystemKey = m.Msg == NativeMethods.WM_SYSCHAR ||
                                   m.Msg == NativeMethods.WM_SYSKEYDOWN ||
                                   m.Msg == NativeMethods.WM_SYSKEYUP;

            if (m.Msg == NativeMethods.WM_KEYDOWN || m.Msg == NativeMethods.WM_SYSKEYDOWN)
            {
                keyEvent.EventType = CefKeyEventType.RawKeyDown;
            }
            else if (m.Msg == NativeMethods.WM_KEYUP || m.Msg == NativeMethods.WM_SYSKEYUP)
            {
                keyEvent.EventType = CefKeyEventType.KeyUp;
            }
            else
            {
                keyEvent.EventType = CefKeyEventType.Char;
            }
            keyEvent.Modifiers = GetKeyboardModifiers(ref m);

            if (this.Renderer != null)
            {
                this.Renderer.SendKeyEvent(keyEvent);
            }
        }
示例#5
0
 /// <summary>
 /// Called after the renderer and JavaScript in the page has had a chance to
 /// handle the event. |event| contains information about the keyboard event.
 /// |os_event| is the operating system event message, if any. Return true if
 /// the keyboard event was handled or false otherwise.
 /// </summary>
 protected virtual bool OnKeyEvent(CefBrowser browser, CefKeyEvent keyEvent, IntPtr osEvent)
 {
     return(false);
 }
示例#6
0
 /// <summary>
 /// Called before a keyboard event is sent to the renderer. |event| contains
 /// information about the keyboard event. |os_event| is the operating system
 /// event message, if any. Return true if the event was handled or false
 /// otherwise. If the event will be handled in OnKeyEvent() as a keyboard
 /// shortcut set |is_keyboard_shortcut| to true and return false.
 /// </summary>
 protected virtual bool OnPreKeyEvent(CefBrowser browser, CefKeyEvent keyEvent, IntPtr os_event, out bool isKeyboardShortcut)
 {
     isKeyboardShortcut = false;
     return(false);
 }
示例#7
0
 /// <summary>
 /// Called before a keyboard event is sent to the renderer. |event| contains
 /// information about the keyboard event. |os_event| is the operating system
 /// event message, if any. Return true if the event was handled or false
 /// otherwise. If the event will be handled in OnKeyEvent() as a keyboard
 /// shortcut set |is_keyboard_shortcut| to true and return false.
 /// </summary>
 protected virtual bool OnPreKeyEvent(CefBrowser browser, CefKeyEvent keyEvent, IntPtr os_event, out bool isKeyboardShortcut)
 {
     isKeyboardShortcut = false;
     return false;
 }
示例#8
0
 /// <summary>
 /// Called after the renderer and JavaScript in the page has had a chance to
 /// handle the event. |event| contains information about the keyboard event.
 /// |os_event| is the operating system event message, if any. Return true if
 /// the keyboard event was handled or false otherwise.
 /// </summary>
 protected virtual bool OnKeyEvent(CefBrowser browser, CefKeyEvent keyEvent, IntPtr osEvent)
 {
     return false;
 }
示例#9
0
        protected override bool OnKeyUp( KeyEvent e )
        {
            if( IsEnabledInHierarchy() && 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.KeyUp,
                        WindowsKeyCode = (int)e.Key /*KeyInterop.VirtualKeyFromKey(arg.Key == Key.System ? arg.SystemKey : arg.Key)*/,
                        NativeKeyCode = (int)e.Key,/*0*/
                        /*IsSystemKey = e.Key == EKeys.System*/
                    };

                    keyEvent.Modifiers = GetCurrentKeyboardModifiers();

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

                //arg.Handled = true;
            }

            return base.OnKeyUp( e );
        }
示例#10
0
        protected override bool OnKeyPress( KeyPressEvent e )
        {
            if( Focused && IsEnabledInHierarchy() && 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( "WebBrowserControl: Caught exception in OnKeyDown(): " + ex.Message );
                }

                //arg.Handled = true;

                return true;
            }

            return base.OnKeyPress( e );
        }
示例#11
0
        public void SendKeyEvent(CefKeyEvent keyEvent)
        {
            if (this.Browser != null)
            {
                var host = this.Browser.GetHost();

                host.SendKeyEvent(keyEvent);
            }
        }