MessageField
Encapsulates the message entry field tied to the currently selected conversation.
1MessageField.getText(): Promise<string>
Gets the current content of the message field.
None
Promise<string>
1MessageField.setText(text: string): void
Sets the message entry field to text. Useful if you want to guide your user with message suggestions.
Name | Type | Description |
---|---|---|
text Required | string | The text to be displayed in the message entry field |
void
1MessageField.typeText(text: string): void
Types the given text
into the message field.
Inserts text
wherever the cursor currently is.
This method may be useful for various bot/simulation scenarios. Additionally, it lets you make it so that any regular keypress lets the user start typing into the message field, even if it is not focused.
To do that, capture the keypress using a regular window event listener, ensure that
the user isn't typing into a different input, and then call this method to type the
key, followed by focus
. Note that TalkJS already does this out-of-the box
when the chat UI iframe has focus and ChatboxOptions​.captureKeyboardEvents is off.
Name | Type | Description |
---|---|---|
text Required | string | The text to be inserted in the message entry field |
void
1MessageField.setVisible(visible: boolean | ConversationPredicate): void
Sets the visibility of the Message Field to a given value or to a certain predicate.
Name | Type | Description |
---|---|---|
visible Required | boolean | ConversationPredicate | A boolean or predicate that outlines the circumstances the message field should be hidden |
void
1MessageField.focus(): void
Focuses the message entry field.
None
void