ChatInput

Text input component for the chat UI. Wraps a TMP_InputField and manages its activation state, message submission to the Chat singleton, and visual visibility via a CanvasGroup. Coordinates with ChatHUD for focus lifecycle.

Definition

Namespace: Paragon.Townskeep.ChatSystem.HUD Assembly: Townskeep.dll

public class ChatInput : ParagonUIBehaviour

Inheritance: SerializedMonoBehaviourParagonBehaviourParagonUIBehaviour → ChatInput

Remarks

ChatInput bridges the UI input field with the Chat messaging system. When the user submits a message, OnSubmit validates the input (rejecting empty/whitespace), sends it via Chat.SendMessage() to the currently active channel (from ChatWindow.Name), clears the input field, and triggers ChatHUD.Unfocus().

The input field starts deactivated (hidden via canvasGroup.alpha = 0). It is activated/deactivated by ChatHUD during focus transitions. When a chat tab is selected while the chat is focused, the input field is re-activated to maintain keyboard focus.

Quick Lookup

Goal
How

Get current message text

chatInput.Message

Show and focus input field

chatInput.ActivateInputField()

Hide and clear input field

chatInput.DeactivateInputField()

Clear text without hiding

chatInput.ClearMessage()

Properties

Message

The current text content of the input field. Read-only accessor to inputField.text.

Methods

Initialize

Called by ChatHUD.Start(). Stores references to the parent HUD and its sub-components, and subscribes to ChatTabs.OnTabSelected.

Parameter
Type
Description

chatHUD

ChatHUD

The parent chat HUD

ActivateInputField

Enables the TMP_InputField, gives it keyboard focus, and makes the input visible by setting canvasGroup.alpha = 1.0.

DeactivateInputField

Removes keyboard focus, disables the TMP_InputField, clears the text, and hides the input by setting canvasGroup.alpha = 0.0.

ClearMessage

Clears the input field text without changing visibility or activation state.

Internal Behavior

OnSubmit (private)

Triggered when the user submits text in the TMP_InputField:

OnTabSelected (private)

Triggered when a chat tab is selected. If the chat is currently focused, re-activates the input field to restore keyboard focus (which is lost when clicking a tab button).

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated