예제 #1
0
 public static async Task GetKeyboardInput()
 {
     //Check if the user is currently typing in a keyboard we have created
     if (TypingOnKeyboard)
     {
         API.HideHudAndRadarThisFrame();
         //Get what the user did this frame
         int Update = API.UpdateOnscreenKeyboard();
         if (Update == 1)
         {
             //If the user stopped editing by pressing enter we get the result and call the callback function with the first argument as true and the second as the text they entered
             string InputText = API.GetOnscreenKeyboardResult();
             if (InputText.Length > 0)
             {
                 TypingOnKeyboard = false;
                 CallbackAction.Invoke(true, InputText);
             }
             else
             {
                 //They didn't write anything - Open the keyboard again to allow them to enter text in order to prevent empty text
                 API.DisplayOnscreenKeyboard(0, "FMMC_KEY_TIP8S", "", "", "", "", "", 200);
             }
         }
         else if (Update == 2 || Update == 3)
         {
             //The user must have exited the keyboard - call the callback with false as first argument indicating that it didn't succeed
             TypingOnKeyboard = false;
             CallbackAction.Invoke(false, "");
         }
     }
 }
예제 #2
0
 public static void OpenKeyboard(Action <bool, string> Callback, string Text = "")
 {
     if (!TypingOnKeyboard)
     {
         //Open the keyboard and save variables needed in "GetKeyboardInput()"
         CallbackAction = Callback;
         API.DisplayOnscreenKeyboard(0, "FMMC_KEY_TIP8S", "", Text, "", "", "", 200);
         TypingOnKeyboard = true;
     }
     else
     {
         //This should probably never happen since it's imposible to press a button in a menu while typing but if it were to happen it's good to know
         Debug.WriteLine("Was asked to open keyboard but keyboard was already open!");
     }
 }