Skip to content

Commit

Permalink
add command-N and focus text field on new window
Browse files Browse the repository at this point in the history
  • Loading branch information
trevyn committed Jul 21, 2024
1 parent 75c21b1 commit f684899
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ impl MyThings for Ui {

impl eframe::App for App {
fn update(&mut self, ctx: &Context, _frame: &mut eframe::Frame) {
let mut request_focus = None;
ctx.input(|i| {
if i.key_pressed(Key::N) && i.modifiers.command {
let mut wheel_windows = WHEEL_WINDOWS.lock().unwrap();
let len = wheel_windows.len();
wheel_windows.push(Default::default());
request_focus = Some(len * 1000);
}
if i.key_pressed(Key::W) && i.modifiers.command {}
});
// ctx.input(|i| {
// if i.key_pressed(Key::ArrowDown) {
// self.line_selected =
Expand Down Expand Up @@ -451,6 +461,10 @@ impl eframe::App for App {
}
ui.label("[command-enter to send]");

if let Some(id) = request_focus {
ui.ctx().memory_mut(|m| m.request_focus(Id::new(id)))
};

if do_it {
let ref mut messages = window.messages;
messages.truncate(do_it_j + 1);
Expand Down

0 comments on commit f684899

Please sign in to comment.