InputMenuOption
Classpublic sealed class InputMenuOption : MenuOptionBase, IMenuOption, IDisposableRepresents a menu option that allows text input from players.
View sourceConstructors
Creates an instance of InputMenuOption.
public InputMenuOption(int maxLength = 16, Func<string, bool>? validator = null, string defaultValue = "", string? hintMessage = null, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- maxLengthintoptionalMaximum input length. Defaults to 16.
- validatorFunc<string, bool>?optionalOptional function to validate input. Returns true if valid.
- defaultValuestringoptionalThe default input value. Defaults to empty string.
- hintMessagestring?optionalOptional hint message to display when waiting for input. Defaults to English prompt.
- updateIntervalMsintoptionalThe interval in milliseconds between text updates. Defaults to 120ms.
- pauseIntervalMsintoptionalThe pause duration in milliseconds before starting the next text update cycle. Defaults to 1000ms.
When using this constructor, the Text property must be manually set to specify the initial text.
Creates an instance of InputMenuOption.
public InputMenuOption(string text, int maxLength = 16, Func<string, bool>? validator = null, string defaultValue = "", string? hintMessage = null, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- textstringThe text content to display.
- maxLengthintoptionalMaximum input length. Defaults to 16.
- validatorFunc<string, bool>?optionalOptional function to validate input. Returns true if valid.
- defaultValuestringoptionalThe default input value. Defaults to empty string.
- hintMessagestring?optionalOptional hint message to display when waiting for input. Defaults to English prompt.
- updateIntervalMsintoptionalThe interval in milliseconds between text updates. Defaults to 120ms.
- pauseIntervalMsintoptionalThe pause duration in milliseconds before starting the next text update cycle. Defaults to 1000ms.
Methods
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public override void Dispose()Gets the display text for this option as it should appear to the specified player.
public override string GetDisplayText(IPlayer player, int displayLine = 0)When a menu option occupies multiple lines, MenuAPI may only need to display a specific line of that option. When LineCount=1 : The displayLine parameter is not needed; return the HTML-formatted string directly. When LineCount>=2 : Check the displayLine parameter: displayLine=0 : Return all content displayLine=1 : Return only the first line content displayLine=2 : Return only the second line content And so on... Note: MenuAPI ensures that the displayLine parameter will not exceed the option's LineCount .
Gets the current input value for the specified player.
public string GetValue(IPlayer player)- playerIPlayerThe player whose value to retrieve.
Sets the input value for the specified player and triggers validation.
public bool SetValue(IPlayer player, string value)Occurs when a player submits a valid input value.
public event EventHandler<MenuOptionValueChangedEventArgs<string>>? ValueChanged