예제 #1
0
        public void OnKey([GeneratedEnum] Android.Views.Keycode primaryCode, [GeneratedEnum] Android.Views.Keycode[] keyCodes)
        {
            ic = CurrentInputConnection;

            if (ic == null)
            {
                return;
            }

            switch (primaryCode)
            {
            case Android.Views.Keycode.Del:
                string selectedText = ic.GetSelectedText(GetTextFlags.None);

                if (string.IsNullOrEmpty(selectedText))
                {
                    ic.DeleteSurroundingText(1, 0);
                }
                else
                {
                    ic.CommitText("", 1);
                }

                break;

            case Android.Views.Keycode.Unknown:
                TextData.LastText = string.Empty;
                Intent intent = new Intent();
                intent.SetClass(this, typeof(CameraActivity));
                intent.SetFlags(ActivityFlags.NewTask);
                StartActivity(intent);
                break;

            default:
                char code = (char)primaryCode;
                ic.CommitText(code.ToString(), 1);
                break;
            }
        }
예제 #2
0
        public void OnKey([GeneratedEnum] Android.Views.Keycode primaryCode, [GeneratedEnum] Android.Views.Keycode[] keyCodes) //Main keyboard input method
        {
            ic = CurrentInputConnection;                                                                                       //to get current input connection

            switch (primaryCode)
            {
            case (Android.Views.Keycode.Del):
                selectedText = ic.GetSelectedText(0);
                if (string.IsNullOrEmpty(selectedText))
                {
                    ic.DeleteSurroundingText(1, 0);
                }
                else
                {
                    ic.CommitText(string.Empty, 1);
                }
                break;

            case (Android.Views.Keycode.CapsLock):    //To toggle caps lock


                if (!CapsFlag)    //caps lock was off
                {
                    CapsKeyboard = new Keyboard(this, Resource.Xml.caps_qwerty);
                    kv.Keyboard  = CapsKeyboard;
                    kv.OnKeyboardActionListener = this;

                    CapsFlag = true;
                }
                else    //caps lock was already onon
                {
                    kv.Keyboard = keyboard;
                    kv.OnKeyboardActionListener = this;
                    CapsFlag = false;
                }
                break;

            case (Android.Views.Keycode.S):    //this is because ASCII value 115 for s is same as android enum for caps lock
            {
                ic.CommitText("s", 1);

                break;
            }

            case (Android.Views.Keycode.ButtonA):    //this is because ASCII value 115 for s is same as android enum for caps lock
            {
                ic.CommitText("/", 1);

                break;
            }

            case (Android.Views.Keycode.C):    //this is because ASCII value 115 for C (caps) is same as android enum for backspace
            {
                ic.CommitText("C", 1);

                break;
            }

            case (Android.Views.Keycode.Num3):    //actually this is done sbutton handling , as i am using Code=10 for my done button, which is code for unused num3
            {
                ic.PerformEditorAction(ImeAction.Send);
                ic.PerformEditorAction(ImeAction.Go);
                ic.PerformEditorAction(ImeAction.Done);


                SplSession.Close();        //closing spell check session

                break;
            }



            default:

                if ((int)primaryCode == 1115)
                {
                    if (!SymbolsFlag)    //symbol view was off
                    {
                        SymbolsKeyboard             = new Keyboard(this, Resource.Xml.Symbols);
                        kv.Keyboard                 = SymbolsKeyboard;
                        kv.OnKeyboardActionListener = this;
                        SymbolsFlag                 = true;
                    }
                    else    //Symbol view was on
                    {
                        kv.Keyboard = keyboard;
                        kv.OnKeyboardActionListener = this;
                        SymbolsFlag = false;
                    }
                    break;
                }

                char code = (char)(primaryCode);



                ic.CommitText(code.ToString(), 1);    // to provides the keystroke to input area according to ascai value of code



                break;
            }
        }