Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send a message by pressing Ctrl + Return or Command ⌘ + Return #245

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/home/room_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,10 +1303,22 @@ impl Widget for RoomScreen {
}
}

// Handle the send message button being clicked.
if self.button(id!(send_message_button)).clicked(&actions) {
let msg_input_widget = self.text_input(id!(message_input));
let entered_text = msg_input_widget.text();
let msg_input_widget = self.text_input(id!(message_input));

let mut send_message_with_shortcut_key = false;
if let Some(key_event) = msg_input_widget.key_down_unhandled(&actions) {

// Windows and linux use control key, mac uses logo key
if key_event.key_code == KeyCode::ReturnKey
&& (key_event.modifiers.control || key_event.modifiers.logo)
{
send_message_with_shortcut_key = true;
}
}

// Handle the send message button being clicked and enter key being pressed.
if self.button(id!(send_message_button)).clicked(&actions) || send_message_with_shortcut_key {
let entered_text = msg_input_widget.text().trim().to_string();
if !entered_text.is_empty() {
let room_id = self.room_id.clone().unwrap();
log!("Sending message to room {}: {:?}", room_id, entered_text);
Expand Down