//This function is called every time a item is selected on the edit menu public static void EditMenuItemSelected(UIMenu Sender, UIMenuItem SelectedItem, int Index) { //Make sure it's not one of the list items being selected if (SelectedItem.GetType() == typeof(UIMenuItem)) { //Check the position (the same as it's index) of the item to see which one it is and trigger the appropriate event if (Sender.MenuItems.FindIndex(item => item == SelectedItem) == 3) { BaseScript.TriggerServerEvent("SimpleText:Server:MoveText", EditID, Game.Player.Character.Position); } if (Sender.MenuItems.FindIndex(item => item == SelectedItem) == 4) { Utils.OpenKeyboard((bool Success, string InputText) => { if (Success) { BaseScript.TriggerServerEvent("SimpleText:Server:EditText", EditID, InputText, ((UIMenuListItem)Sender.MenuItems[0]).Index, ((UIMenuListItem)Sender.MenuItems[1]).Index, ((UIMenuListItem)Sender.MenuItems[2]).Index); } else { Main.ShowNotification("~r~Something went wrong... ~s~Remember to press ~b~ENTER ~s~when you are done writing."); } }, Main.ActiveText[EditID].Text); } else if (Sender.MenuItems.FindIndex(item => item == SelectedItem) == 5) { BaseScript.TriggerServerEvent("SimpleText:Server:DeleteText", EditID); EditMenu.Visible = false; ListMenu.Visible = true; } } }
public static void CreateMenuItemSelected(UIMenu Sender, UIMenuItem SelectedItem, int Index) { if (SelectedItem.GetType() == typeof(UIMenuItem)) { //Open the keyboard and provide a callback (a action in this function) that will be called when the user has finished typing Utils.OpenKeyboard((bool Success, string InputText) => { if (Success) { BaseScript.TriggerServerEvent("SimpleText:Server:CreateText", InputText, Game.Player.Character.Position, ((UIMenuListItem)Sender.MenuItems[0]).Index, ((UIMenuListItem)Sender.MenuItems[1]).Index, ((UIMenuListItem)Sender.MenuItems[2]).Index); } else { Main.ShowNotification("~r~Something went wrong... ~s~Remember to press ~b~ENTER ~s~when you are done writing."); } }); } }