コード例 #1
0
ファイル: Form1.cs プロジェクト: Perikles/AwesomiumSharp
        void WebForm_KeyUp( object sender, KeyEventArgs e )
        {
            WebKeyboardEvent keyEvent = new WebKeyboardEvent { Type = WebKeyType.KeyUp, VirtualKeyCode = (int)e.KeyCode };

            if ( !webView.IsDisposed )
                webView.InjectKeyboardEvent( keyEvent );
        }
コード例 #2
0
ファイル: UIManager.cs プロジェクト: fusspawn/sobriety
 static void EventInput_KeyUp(object sender, KeyEventArgs e)
 {
     WebKeyboardEvent Event = new WebKeyboardEvent();
     Event.Type = WebKeyType.KeyUp;
     Event.VirtualKeyCode = KeyMappings.MapKeys(e.KeyCode);
     Event.Modifiers = KeyMappings.MapModifiers();
     UILayer.InjectKeyboardEvent(Event);
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Perikles/AwesomiumSharp
        void WebForm_KeyPress( object sender, KeyPressEventArgs e )
        {
            WebKeyboardEvent keyEvent = new WebKeyboardEvent { Type = WebKeyType.Char, Text = new ushort[] { e.KeyChar, 0, 0, 0 } };

            if ( !webView.IsDisposed )
                webView.InjectKeyboardEvent( keyEvent );
        }
コード例 #4
0
 void InjectKeyDown(WebKeyboardEvent keyEvent, ushort keyValue)
 {
     keyEvent.type = WebKeyType.KeyDown;
     keyEvent.virtualKeyCode = keyValue;
     keyEvent.nativeKeyCode = keyValue;
     webView.InjectKeyboardEvent(keyEvent);
 }
コード例 #5
0
ファイル: UIManager.cs プロジェクト: fusspawn/sobriety
 static void EventInput_CharEntered(object sender, CharacterEventArgs e)
 {
     WebKeyboardEvent Event = new WebKeyboardEvent();
     Event.Type = WebKeyType.Char;
     Event.NativeKeyCode = e.Character;
     Event.Text = new ushort[] { e.Character, 0, 0, 0 };
     Event.Modifiers = KeyMappings.MapModifiers();
     UILayer.InjectKeyboardEvent(Event);
 }
コード例 #6
0
 void InjectKeyPress(WebKeyboardEvent keyEvent, ushort keyValue)
 {
     keyEvent.type = WebKeyType.Char;
     keyEvent.text = new ushort[] { keyValue, 0, 0, 0 };
     webView.InjectKeyboardEvent(keyEvent);
 }
コード例 #7
0
        public void InjectKeyboardEvent()
        {
            Microsoft.Xna.Framework.Input.Keys[] keys = inputHandler.KeyboardManager.KeysPressed();


            WebKeyboardEvent keyEvent = new WebKeyboardEvent();
            
            ushort keyValue = 0;

            List<Microsoft.Xna.Framework.Input.Keys> regularKeys = new List<Microsoft.Xna.Framework.Input.Keys>();
            bool IsShiftDown = false;
            bool IsCtrlDown = false;
            bool IsAltDown = false;
            bool IsWinDown = false;
            
            // what special keys are down?
            for (int k = keys.Length-1; k >= 0; k--)
            {
                switch (keys[k])
                {
                    case Microsoft.Xna.Framework.Input.Keys.LeftShift:
                    case Microsoft.Xna.Framework.Input.Keys.RightShift:
                        IsShiftDown = true;                        
                        break;
                    case Microsoft.Xna.Framework.Input.Keys.LeftControl:
                    case Microsoft.Xna.Framework.Input.Keys.RightControl:
                        IsCtrlDown = true;
                        break;
                    case Microsoft.Xna.Framework.Input.Keys.LeftAlt:
                    case Microsoft.Xna.Framework.Input.Keys.RightAlt:
                        IsAltDown = true;
                        break;
                    case Microsoft.Xna.Framework.Input.Keys.LeftWindows:
                    case Microsoft.Xna.Framework.Input.Keys.RightWindows:
                        IsWinDown = true;
                        break;
                    default:
                        regularKeys.Add(keys[k]);
                        break;
                }
            }
            

            foreach (Microsoft.Xna.Framework.Input.Keys key in regularKeys)
            {
                switch (key)
                {
                    case Microsoft.Xna.Framework.Input.Keys.Add:
                        keyValue = (ushort)'+';
                        InjectKeyPress(keyEvent, keyValue);
                        break;
                    case Microsoft.Xna.Framework.Input.Keys.Back:
                        keyValue = (ushort)'\b';
                        InjectKeyDown(keyEvent, keyValue);
                        break;
                    case Microsoft.Xna.Framework.Input.Keys.Delete:
                        keyValue = (ushort)127;
                        InjectKeyDown(keyEvent, keyValue);
                        break;
                    default:
                        keyValue = (ushort)key;
                        
                        if (!IsShiftDown)
                            keyValue += 32;

                        InjectKeyPress(keyEvent, keyValue);
                        break;
                }
            }

        }
コード例 #8
0
    void OnGUI()
    {
        Event e = Event.current;

        //We only inject input when the GameObject has focus
        if (e.isKey == true && isFocused == true){

            if(e.type == EventType.KeyDown){

                if(e.character == 0)
                {
                    WebKeyboardEvent keyEvent = new WebKeyboardEvent();
                    keyEvent.type = WebKeyType.KeyDown;
                    keyEvent.virtualKeyCode = MapKeys(e);
                    webView.InjectKeyboardEvent(keyEvent);
                }
                else
                {
                    WebKeyboardEvent keyEvent = new WebKeyboardEvent();
                    keyEvent.type = WebKeyType.Char;
                    keyEvent.text =  new ushort[] { e.character, 0, 0, 0 };
                    webView.InjectKeyboardEvent(keyEvent);
                }
            }

            if(e.type == EventType.KeyUp){
                WebKeyboardEvent keyEvent = new WebKeyboardEvent();
                keyEvent.type = WebKeyType.KeyUp;
                keyEvent.virtualKeyCode = MapKeys(e);
                webView.InjectKeyboardEvent(keyEvent);
            }
        }

        // We unfocus each WebView whenever a MouseDown event is encountered in OnGUI
        // the actual focusing of a specific element occurs in OnMouseDown
        if(e.type == EventType.MouseDown)
        {
            Unfocus();
        }

        if(e.type == EventType.ScrollWheel && isScrollable == true)
        {
            webView.InjectMouseWheel((int)e.delta.y * -10);
        }
    }
コード例 #9
0
ファイル: Form1.cs プロジェクト: keremkusmezer/AwesomiumSharp
 void WebForm_KeyUp(object sender, KeyEventArgs e)
 {
     WebKeyboardEvent keyEvent = new WebKeyboardEvent();
     keyEvent.type = WebKeyType.KeyUp;
     keyEvent.virtualKeyCode = (int)e.KeyCode;
     webView.InjectKeyboardEvent(keyEvent);
 }
コード例 #10
0
ファイル: Form1.cs プロジェクト: keremkusmezer/AwesomiumSharp
 void WebForm_KeyPress(object sender, KeyPressEventArgs e)
 {
     WebKeyboardEvent keyEvent = new WebKeyboardEvent();
     keyEvent.type = WebKeyType.Char;
     keyEvent.text = new ushort[] { e.KeyChar, 0, 0, 0 };
     webView.InjectKeyboardEvent(keyEvent);
 }