Skip to main content

DebugInput

Struct DebugInput 

Source
pub struct DebugInput { /* private fields */ }
Expand description

The debug UI’s input: the window’s events, fed in their order, by the engine from its window (roadmap M7.10) or by a test.

DebugUi::frame takes the events of one frame: at most one press and one release of the left button, so that a click is judged where it was pressed and where it was released, however late the frame. The frame ends at the release, so that a drag ends where the button went up; a press after a release, or after text or keys, waits for the next frame, so that what was typed goes to the field that had the keyboard. It ends too at a press of a key whose meaning a text field leaves to its caller, Enter (and the keypad’s), Tab, Up, Down, PageUp and PageDown, which the caller handles after the field: a console then runs a line with the text typed before its Enter only, and goes back in its history before an Enter that follows. Pointer moves in a row are kept as the last one, and past 4096 events the oldest go: a debug UI not drawn for a while should clear its input when it is drawn again.

Implementations§

Source§

impl DebugInput

Source

pub fn new() -> Self

An input with no events, the pointer at (0, 0) and nothing down.

Source

pub fn pointer_moved(&mut self, position: Vec2)

The pointer moved to position: the output’s pixels from its top-left corner, as nadir_input::Input::pointer gives it.

Source

pub fn button(&mut self, button: MouseButton, pressed: bool)

A mouse button went down or up. The debug UI uses the left one only.

Source

pub fn wheel(&mut self, lines: Vec2)

The wheel turned by lines: +y is away from the user, which scrolls toward the top.

Source

pub fn key(&mut self, key: Key, pressed: bool, repeat: bool)

A key went down, up, or repeated while held (repeat): a repeat is a press again, as editing wants.

Source

pub fn text(&mut self, text: &str)

Text was typed. Control characters, a tab and newlines among them, are left out: the keys that make them are seen as keys.

Source

pub fn focus_lost(&mut self)

The window lost the focus: the button and the modifiers are let go, and a widget held is released without a click.

Source

pub fn is_empty(&self) -> bool

Whether events wait to be taken.

Source

pub fn clear(&mut self)

Drops the events not taken, keeping where they leave the pointer and what they leave held: for a debug UI drawn again after frames it was not, so that the clicks the game had then are not replayed on it.

Trait Implementations§

Source§

impl Clone for DebugInput

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DebugInput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DebugInput

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.