Skip to content

Commit

Permalink
Use enter to submit code
Browse files Browse the repository at this point in the history
  • Loading branch information
bash committed Feb 13, 2023
1 parent 117a8bf commit 4052ad8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::transmit_info::transit_info_message;
use crate::update;
use crate::widgets::{cancel_button, page, page_with_content, CancelLabel, MIN_BUTTON_SIZE};
use eframe::egui::{Button, ProgressBar, TextEdit, Ui};
use egui::Key;
use portal_proc_macro::states;
use portal_wormhole::receive::{
connect, ConnectResult, ConnectingController, ReceiveRequestController, ReceiveResult,
Expand Down Expand Up @@ -139,7 +140,13 @@ fn show_receive_file_page(ui: &mut Ui, code: &mut String) -> Option<ReceivePageR
"Enter the transmit code from the sender",
"📥",
|ui| {
ui.add(TextEdit::singleline(code).hint_text("Code"));
if ui
.add(TextEdit::singleline(code).hint_text("Code"))
.lost_focus()
&& ui.input(|input| input.key_pressed(Key::Enter))
{
return Some(ReceivePageResponse::Connect);
}
ui.add_space(5.0);

let input_empty = code.is_empty() || code.chars().all(|c| c.is_whitespace());
Expand Down

0 comments on commit 4052ad8

Please sign in to comment.