registration now has working form

This commit is contained in:
filipriec
2025-08-29 12:22:25 +02:00
parent cf79bc7bd5
commit 72c2691a17
7 changed files with 241 additions and 65 deletions

View File

@@ -330,6 +330,44 @@ impl EventHandler {
}
}
}
} else if let Page::Register(register_page) = &mut router.current {
use crossterm::event::{KeyCode, KeyModifiers};
// Inside canvas: at the last field, 'j' or Down moves focus to buttons
if !app_state.ui.focus_outside_canvas {
let last_idx = register_page.editor.data_provider().field_count().saturating_sub(1);
let at_last = register_page.editor.current_field() >= last_idx;
if at_last
&& matches!(
(key_code, modifiers),
(KeyCode::Char('j'), KeyModifiers::NONE) | (KeyCode::Down, _)
)
{
app_state.ui.focus_outside_canvas = true;
app_state.focused_button_index = 0; // focus "Register" button
register_page.editor.set_mode(CanvasMode::ReadOnly);
return Ok(EventOutcome::Ok("Focus moved to buttons".to_string()));
}
}
// Only forward to the canvas while focus is inside it
if !app_state.ui.focus_outside_canvas {
match register_page.handle_key_event(key_event) {
KeyEventOutcome::Consumed(Some(msg)) => {
self.command_message = msg;
return Ok(EventOutcome::Ok("Register input updated".to_string()));
}
KeyEventOutcome::Consumed(None) => {
return Ok(EventOutcome::Ok("Register input updated".to_string()));
}
KeyEventOutcome::Pending => {
return Ok(EventOutcome::Ok("Waiting for next key...".to_string()));
}
KeyEventOutcome::NotMatched => {
// fall through
}
}
}
}
}
if toggle_sidebar(