예제 #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, "");
         }
     }
 }