Skip to main content

shuyi_platform/
text_input.rs

1//! [`TextInput`]: the system's own keyboard, for a device where the player
2//! doesn't type on keys (a console's software keyboard, Steam's on-screen
3//! one on the Steam Deck, which is the game's to fill: its ticket 0903).
4//!
5//! A screen asks through its context
6//! ([`Ctx::system_keyboard`](shuyi_ui::Ctx::system_keyboard)); `App` opens
7//! the keyboard after the frame that asked and hands the answer back
8//! before a later one ([`shuyi_ui::system_keyboard`] has the handshake).
9
10pub use shuyi_ui::system_keyboard::{TextAnswer, TextAsk};
11
12/// A system keyboard a backend offers ([`Platform::text_input`]).
13///
14/// [`Platform::text_input`]: crate::Platform::text_input
15pub trait TextInput {
16    /// Shows the keyboard for `ask`: its prompt, the text to start from and
17    /// the most characters. `false` if it can't now (the system refused);
18    /// the screen then hears [`TextAnswer::Cancelled`].
19    fn open(&mut self, ask: &TextAsk) -> bool;
20
21    /// What the player did, once they closed the keyboard; `None` while it
22    /// is open, or when none is.
23    fn poll(&mut self) -> Option<TextAnswer>;
24}