diff --git a/src/file_manager/main.rs b/src/file_manager/main.rs index d01fd0bf78b4c397105dc7cb1acc93277c237795..d79515fd6ac75a41cc5e6cfb569c61f5af23ec6f 100644 --- a/src/file_manager/main.rs +++ b/src/file_manager/main.rs @@ -22,7 +22,7 @@ use mime::TopLevel as MimeTop; use orbclient::{Color, Renderer, WindowFlag}; use orbimage::Image; -use orbtk::{Window, Point, Rect, Button, List, Entry, Label, Place, Resize, Text, TextBox, Click}; +use orbtk::{Window, Point, Rect, Button, List, Entry, Label, Place, Resize, Text, TextBox, Click, Enter}; const ICON_SIZE: i32 = 32; @@ -416,6 +416,19 @@ impl FileManager { window.add(&file_button); // } DESIGN + { + let text_box = text_box.clone(); + let tx = tx.clone(); + let window_ptr = window.deref_mut() as *mut Window; + text_box.on_enter(move |text_box: &TextBox| { + let name = text_box.text.get(); + if ! name.is_empty() { + tx.send(FileManagerCommand::CreateFile(name)).unwrap(); + } + unsafe { (&mut *window_ptr).close(); } + }); + } + { let window_ptr = window.deref_mut() as *mut Window; cancel_button.on_click(move |_button: &Button, _point: Point| {