Struct Keybind

Source
pub struct Keybind<'a, B: Bind> { /* private fields */ }
Expand description

A keybind (hotkey) widget for egui.

Implementations§

Source§

impl<'a, B: Bind> Keybind<'a, B>

Source

pub fn new(bind: &'a mut B, id: impl Into<Id>) -> Self

Create a new Keybind for a given Bind.

§Arguments
Source

pub fn with_text(self, text: &'a str) -> Self

Set the text of the Keybind. This will be displayed next to the keybind widget (and used for accessibility).

You can remove the text by setting it to an empty string. By default there is no text.

Source

pub fn with_bind(self, bind: &'a mut B) -> Self

Set the bind of the Keybind.

By default this is the bind that was passed to new.

Source

pub fn with_id(self, id: impl Into<Id>) -> Self

Set the ID of the Keybind in egui’s memory.

By default this is the ID that was passed in new.

Source

pub fn with_reset_key(self, key: Option<Key>) -> Self

Set the key that resets the Keybind. If None, the Keybind will never reset to its’ previous value.

By default this is None.

Source

pub fn with_reset(self, prev_bind: B) -> Self

Set the bind that the Keybind will reset to after the reset key gets pressed.

By default this is the same as the bind passed to new.

Source

pub fn with_modifier_names(self, modifier_names: &'a ModifierNames<'a>) -> Self

Set the modifier names to use for the Keybind. By default this is ModifierNames::NAMES.

Trait Implementations§

Source§

impl<B: Bind> Widget for Keybind<'_, B>

Source§

fn ui(self, ui: &mut Ui) -> Response

Allocate space, interact, paint, and return a Response. Read more

Auto Trait Implementations§

§

impl<'a, B> Freeze for Keybind<'a, B>
where B: Freeze,

§

impl<'a, B> RefUnwindSafe for Keybind<'a, B>
where B: RefUnwindSafe,

§

impl<'a, B> Send for Keybind<'a, B>
where B: Send,

§

impl<'a, B> Sync for Keybind<'a, B>
where B: Sync,

§

impl<'a, B> Unpin for Keybind<'a, B>
where B: Unpin,

§

impl<'a, B> !UnwindSafe for Keybind<'a, B>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.