mirror of
https://github.com/storytold/deckcraft.git
synced 2026-11-29 01:35:14 +01:00
The slide takes the keyboard back when nothing has it and Tab has work
This commit is contained in:
1 parent
c74671d7c6
commit
d532ff66a1
2 files changed
+24
-5
No files matched your search
@@ -79,8 +79,9 @@ impl SlideApp {
|
||||
|
||||
/// Ends the document window's pass, after the views; `before` is the presentation the last pass drew. The pass's
|
||||
/// input has changed what Tab has to do, so the document is declared again. A presentation that opened or became
|
||||
/// active asks for the focus, and so does the document when a dialog, menu or popup closes and leaves nothing
|
||||
/// focused. Both wait for the last of them to close.
|
||||
/// active asks for the focus. So does the document with nothing focused, when a dialog, menu or popup has closed, and
|
||||
/// while Tab has work on the slide (a ribbon field committed with Enter leaves nothing focused). All wait for the
|
||||
/// last dialog, menu or popup to close.
|
||||
pub(super) fn finish_document(&mut self, ctx: &egui::Context, before: Option<u64>) {
|
||||
let drawn = self.document_focus.drawn;
|
||||
if drawn.is_none() {
|
||||
@@ -88,7 +89,8 @@ impl SlideApp {
|
||||
self.document_focus.uncovered = 0;
|
||||
return;
|
||||
}
|
||||
host_canvas(ctx, self.document_keeps_tab(ctx));
|
||||
let keeps_tab = self.document_keeps_tab(ctx);
|
||||
host_canvas(ctx, keeps_tab);
|
||||
if drawn != before {
|
||||
self.document_focus.opened = ASKING_PASSES;
|
||||
}
|
||||
@@ -96,11 +98,11 @@ impl SlideApp {
|
||||
self.document_focus.uncovered = ASKING_PASSES;
|
||||
return;
|
||||
}
|
||||
let unfocused = ctx.memory(|m| m.focused().is_none());
|
||||
let DocumentFocus { opened, uncovered, .. } = &mut self.document_focus;
|
||||
if *opened == 0 && *uncovered == 0 {
|
||||
if *opened == 0 && *uncovered == 0 && !(unfocused && keeps_tab) {
|
||||
return;
|
||||
}
|
||||
let unfocused = ctx.memory(|m| m.focused().is_none());
|
||||
if unfocused || (*opened > 0 && Self::focus_is_free(ctx)) {
|
||||
(*opened, *uncovered) = (0, 0);
|
||||
focus_document(ctx);
|
||||
|
||||
@@ -98,6 +98,23 @@ fn after_a_dialog_closes_tab_selects_the_next_object() {
|
||||
assert_eq!((selected(&h), focused(&h)), (vec![first], Some(document_id())));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn after_enter_in_a_ribbon_field_tab_selects_the_next_object() {
|
||||
let mut h = harness();
|
||||
h.state_mut().ui.tab = "Transitions".into();
|
||||
tab(&mut h);
|
||||
let objects: Vec<_> = h.state().session.active().unwrap().shapes().iter().map(|s| s.id).collect();
|
||||
assert_eq!(selected(&h), objects[..1]);
|
||||
h.get_by_role_and_label(Role::TextInput, "Duration value").focus();
|
||||
h.run_steps(2);
|
||||
assert!(h.ctx.text_edit_focused());
|
||||
press(&mut h, Modifiers::NONE, Key::Enter);
|
||||
assert!(!h.ctx.text_edit_focused(), "Enter commits the field");
|
||||
assert!(h.state().session.active().unwrap().selection.text.is_none(), "and reaches nothing on the slide");
|
||||
tab(&mut h);
|
||||
assert_eq!((selected(&h), focused(&h)), (vec![objects[1]], Some(document_id())));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_press_in_the_sorter_takes_the_keyboard_from_a_focused_button() {
|
||||
let mut h = harness();
|
||||
|
||||
Reference in new issue
Block a user