pub struct Ask<T> { /* private fields */ }Expand description
A question and its answers, each a T the screen acts on.
Implementations§
Source§impl<T: Copy + PartialEq> Ask<T>
impl<T: Copy + PartialEq> Ask<T>
Sourcepub const ACTIONS: &'static [UiAction] = crate::input::NAVIGATION
pub const ACTIONS: &'static [UiAction] = crate::input::NAVIGATION
What a question reacts to (handle), for the
screen that shows it to declare
(Screen::actions).
Sourcepub fn new(
key: &'static str,
answers: impl IntoIterator<Item = (T, &'static str)>,
) -> Self
pub fn new( key: &'static str, answers: impl IntoIterator<Item = (T, &'static str)>, ) -> Self
The question of the text key key with answers (each an answer
and the text key of its name), the first in focus. Cancel does
nothing until cancelled_by names an answer.
Sourcepub fn focused_on(self, answer: T) -> Self
pub fn focused_on(self, answer: T) -> Self
The same question focused on answer (on the first while it isn’t
one of the answers).
Sourcepub fn cancelled_by(self, answer: T) -> Self
pub fn cancelled_by(self, answer: T) -> Self
The same question, which Cancel answers with answer (going back,
say).
Sourcepub fn handle<A: ActionSet, V>(
&mut self,
action: A,
audio: &mut AudioQueue<V>,
) -> Option<T>
pub fn handle<A: ActionSet, V>( &mut self, action: A, audio: &mut AudioQueue<V>, ) -> Option<T>
An action while the question is open. The cursor’s keys move the
focus to the next answer (right and down) or the one before (left
and up), going round at the ends, with the menu’s move sound on
audio. Confirm gives the answer in focus, Cancel the answer it
stands for (cancelled_by); anything else
gives nothing. An answer’s own sound is the screen’s to play: what
it does may still be refused.