예제 #1
0
        private void HandleKeyInput()
        {
            List <Event> keyEvents = browser.UIHandler.KeyEvents;

            if (keyEvents.Count == 0)
            {
                return;
            }
            foreach (Event item in keyEvents)
            {
                int windowsKeyCode = KeyMappings.GetWindowsKeyCode(item);
                if (item.character == '\n')
                {
                    item.character = '\r';
                }
                if (item.character != 0 && item.type == EventType.KeyDown)
                {
                    BrowserNative.zfb_characterEvent(browser.browserId, item.character, windowsKeyCode);
                }
                else
                {
                    BrowserNative.zfb_keyEvent(browser.browserId, item.type == EventType.KeyDown, windowsKeyCode);
                }
            }
        }
        private void HandleKeyInput(List <Event> keyEvents)
        {
#if ZF_OSX
            ReconstructInputs(keyEvents);
#endif

            foreach (var ev in keyEvents)
            {
                var keyCode = KeyMappings.GetWindowsKeyCode(ev);
                if (ev.character == '\n')
                {
                    ev.character = '\r';                              //'cuz that's what Chromium expects
                }
                if (ev.character == 0)
                {
                    if (ev.type == EventType.KeyDown)
                    {
                        keysToReleaseOnFocusLoss.Add(ev.keyCode);
                    }
                    else
                    {
                        keysToReleaseOnFocusLoss.Remove(ev.keyCode);
                    }
                }

//			if (false) {
//				if (ev.character != 0) Debug.Log("k >>> " + ev.character);
//				else if (ev.type == EventType.KeyUp) Debug.Log("k ^^^ " + ev.keyCode);
//				else if (ev.type == EventType.KeyDown) Debug.Log("k vvv " + ev.keyCode);
//			}

                FireCommands(ev);

                if (ev.character != 0 && ev.type == EventType.KeyDown)
                {
#if ZF_LINUX
                    //It seems, on Linux, we don't get keydown, keypress, keyup, we just get a keypress, keyup.
                    //So, fire the keydown just before the keypress.
                    BrowserNative.zfb_keyEvent(browser.browserId, true, keyCode);
                    //Thanks for being consistent, Unity.
#endif

                    BrowserNative.zfb_characterEvent(browser.browserId, ev.character, keyCode);
                }
                else
                {
                    BrowserNative.zfb_keyEvent(browser.browserId, ev.type == EventType.KeyDown, keyCode);
                }
            }
        }