InputComponent
Classpublic class InputComponent : MenuValueComponent<string>, IMenuComponentA selectable line whose value the player types into chat.
Activating starts a chat capture for that player only: the next message they send becomes the value and never reaches the chat. Activating again while waiting cancels.
View sourceConstructors
InputComponent(string, string, Func<string, bool>?, Action<MenuValueChangedContext<string>>?, string?)
Creates an input.
public InputComponent(string text = "", string defaultValue = "", Func<string, bool>? validator = null, Action<MenuValueChangedContext<string>>? onChanged = null, string? id = null)- textstringoptionalThe label to display.
- defaultValuestringoptionalThe value a player starts with.
- validatorFunc<string, bool>?optionalDecides whether a typed value is acceptable.
- onChangedAction<MenuValueChangedContext<string>>?optionalRuns after the value changes.
- idstring?optionalA stable id, or null to generate one.
Properties
The colour of AcceptedText.
public string? AcceptedColor { get; set; }The text shown briefly after a value is accepted.
public string AcceptedText { get; set; }The text shown while no value has been entered.
public string EmptyText { get; set; }The message sent to the player when the capture starts, or null to send nothing.
public string? HintMessage { get; set; }The colour of InvalidText.
public string? InvalidColor { get; set; }The text shown briefly after a value is rejected.
public string InvalidText { get; set; }The longest value accepted. Longer input is cut. Never below one.
public int MaxLength { get; set; }How long an accepted or invalid status stays on screen, in milliseconds.
public int StatusDurationMs { get; set; }Decides whether a typed value is acceptable, or null to accept anything non-empty.
public Func<string, bool>? Validator { get; set; }The colour of WaitingForInputText.
public string? WaitingForInputColor { get; set; }The text shown while waiting for the player to type.
public string WaitingForInputText { get; set; }Methods
Adjusts a value before it is stored.
protected override string Coerce(IMenuSession session, string value)- sessionIMenuSessionThe session the value belongs to.
- valuestringThe value being stored.
Used for clamping into a range or into the bounds of a list.
Offers an action to this component before the menu handles it.
public override ValueTask<bool> HandleActionAsync(MenuActionContext context)- contextMenuActionContextThe action being dispatched.
Only the focused component is offered actions. Returning true is how a component takes over a key that would otherwise navigate or close the menu.
Whether this component needs a new frame even though nothing invalidated the session.
public override bool NeedsRedraw(IMenuSession session, DateTime now)- sessionIMenuSessionThe session asking.
- nowDateTimeThe current time.
Asked once per tick for every visible component of an otherwise clean session, so keep the check cheap. Animated text and live values are what this exists for.
Produces this component's renderer-agnostic output.
public override MenuNode Render(IMenuComponentRenderContext context)- contextIMenuComponentRenderContextThe player and focus state to draw for.