Close row editors with Enter
This commit is contained in:
parent
c0716e80e1
commit
c7d88cfc0a
|
|
@ -1127,6 +1127,11 @@ impl App {
|
|||
}
|
||||
});
|
||||
});
|
||||
if ctx.input(|input| {
|
||||
input.key_pressed(egui::Key::Enter) && input.modifiers == egui::Modifiers::NONE
|
||||
}) {
|
||||
close = true;
|
||||
}
|
||||
if close {
|
||||
open = false;
|
||||
}
|
||||
|
|
@ -1233,6 +1238,11 @@ impl App {
|
|||
ui.add(egui::Label::new(&preview.decisions).wrap());
|
||||
}
|
||||
});
|
||||
if ctx.input(|input| {
|
||||
input.key_pressed(egui::Key::Enter) && input.modifiers == egui::Modifiers::NONE
|
||||
}) {
|
||||
close = true;
|
||||
}
|
||||
if close {
|
||||
open = false;
|
||||
}
|
||||
|
|
@ -2176,6 +2186,21 @@ mod tests {
|
|||
render(app, ctx, size, events)
|
||||
}
|
||||
|
||||
fn press_enter(app: &mut App, ctx: &egui::Context, size: [f32; 2]) {
|
||||
render(
|
||||
app,
|
||||
ctx,
|
||||
size,
|
||||
vec![egui::Event::Key {
|
||||
key: egui::Key::Enter,
|
||||
physical_key: None,
|
||||
pressed: true,
|
||||
repeat: false,
|
||||
modifiers: egui::Modifiers::NONE,
|
||||
}],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gaps_appear_between_source_rows_without_becoming_editable_events() {
|
||||
let mut app = sample();
|
||||
|
|
@ -2255,7 +2280,8 @@ mod tests {
|
|||
.1;
|
||||
let close = labels.iter().find(|(s, _)| s == "Close").unwrap().1;
|
||||
assert!(close.top() > gap_choice.bottom());
|
||||
app.row_details = false;
|
||||
press_enter(&mut app, &ctx, [860.0, 900.0]);
|
||||
assert!(!app.row_details);
|
||||
let labels = render(&mut app, &ctx, [860.0, 900.0], vec![]);
|
||||
let button = labels
|
||||
.iter()
|
||||
|
|
@ -2984,6 +3010,8 @@ mod tests {
|
|||
click_size(&mut app, &ctx, edit, size);
|
||||
assert!(app.row_details);
|
||||
assert_eq!(app.selected_row, Some(2));
|
||||
press_enter(&mut app, &ctx, size);
|
||||
assert!(!app.row_details);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in New Issue