Allow either Enter or Return for sending a message.

This commit is contained in:
Darren Salt 2024-01-08 11:10:32 +00:00
parent 100568f955
commit 140f7a0871

View File

@ -709,9 +709,9 @@ impl<'a> Widget for Chat<'a> {
} else if keyboard_capturer == Some(id) {
events.push(Event::Focus(state.ids.chat_input));
}
// If enter is pressed and the input box is not empty, send the current message.
// If either Return or Enter is pressed and the input box is not empty, send the current message.
else if ui.widget_input(state.ids.chat_input).presses().key().any(
|key_press| matches!(key_press.key, Key::Return if !state.input.message.is_empty()),
|key_press| matches!(key_press.key, Key::Return | Key::NumPadEnter if !state.input.message.is_empty()),
) {
let msg = state.input.message.clone();
state.update(|s| {