pub struct Messages {
pub messages: Vec<Message>,
pub bot_context: Option<BotContext>,
pub templates: HashMap<LiveId, LivePtr>,
/* private fields */
}Expand description
View over a conversation with messages.
This is mostly a dummy widget. Prefer using and adapting crate::widgets::chat::Chat instead.
Fields§
§messages: Vec<Message>The list of messages rendered by this widget.
bot_context: Option<BotContext>Used to get bot information.
templates: HashMap<LiveId, LivePtr>Registry of DSL templates used by custom content widgets.
This is exposed as it is for easy manipulation and it’s passed to BotClient::content_widget method allowing it to create widgets with [WidgetRef::new_from_ptr].
Implementations§
Source§impl Messages
impl Messages
Sourcepub fn is_at_bottom(&self) -> bool
pub fn is_at_bottom(&self) -> bool
Check if we’re at the end of the messages list.
pub fn user_scrolled(&self) -> bool
Sourcepub fn scroll_to_bottom(&mut self, cx: &mut Cx, triggered_by_stream: bool)
pub fn scroll_to_bottom(&mut self, cx: &mut Cx, triggered_by_stream: bool)
Jump to the end of the list instantly.
Sourcepub fn set_message_editor_visibility(&mut self, index: usize, visible: bool)
pub fn set_message_editor_visibility(&mut self, index: usize, visible: bool)
Show or hide the editor for a message.
Limitation: Only one editor can be shown at a time. If you try to show another editor, the previous one will be hidden. If you try to hide an editor different from the one currently shown, nothing will happen.
Sourcepub fn current_editor_text(&self) -> Option<String>
pub fn current_editor_text(&self) -> Option<String>
If currently editing a message, this will return the text in it’s editor.
Sourcepub fn current_editor_index(&self) -> Option<usize>
pub fn current_editor_index(&self) -> Option<usize>
If currently editing a message, this will return the index of the message.
Sourcepub fn set_messages(&mut self, messages: Vec<Message>, scroll_to_bottom: bool)
pub fn set_messages(&mut self, messages: Vec<Message>, scroll_to_bottom: bool)
Set the messages and defer a scroll to bottom if requested.