Trait Bind

Source
pub trait Bind: Clone {
    // Required methods
    fn set(
        &mut self,
        keyboard: Option<KeyboardShortcut>,
        pointer: Option<PointerButton>,
    );
    fn format(&self, names: &ModifierNames<'_>, is_mac: bool) -> String;
    fn pressed(&self, input: &mut InputState) -> bool;
}
Expand description

A trait can can be used for keybindings.

Must have a function to update the keybinding with a given Key and [Modifiers], aswell as a method that formats the keybinding as a String.

Must implement Clone.

Required Methods§

Source

fn set( &mut self, keyboard: Option<KeyboardShortcut>, pointer: Option<PointerButton>, )

Set the keybind with a given KeyboardShortcut and/or PointerButton.

§Arguments
Source

fn format(&self, names: &ModifierNames<'_>, is_mac: bool) -> String

Format the current keybind as a String.

§Arguments
  • names - The ModifierNames to use.
  • is_mac - Whether to use MacOS symbols.
§Returns

The formatted keybind as a String.

Source

fn pressed(&self, input: &mut InputState) -> bool

Check if the keybind is pressed.

§Arguments
§Returns

Whether the keybind is pressed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Bind for Option<PointerButton>

Source§

fn set( &mut self, _keyboard: Option<KeyboardShortcut>, pointer: Option<PointerButton>, )

Source§

fn format(&self, _names: &ModifierNames<'_>, _is_mac: bool) -> String

Source§

fn pressed(&self, input: &mut InputState) -> bool

Source§

impl Bind for Option<Key>

Source§

fn set( &mut self, keyboard: Option<KeyboardShortcut>, _pointer: Option<PointerButton>, )

Source§

fn format(&self, _names: &ModifierNames<'_>, _is_mac: bool) -> String

Source§

fn pressed(&self, input: &mut InputState) -> bool

Source§

impl Bind for Option<KeyboardShortcut>

Source§

fn set( &mut self, keyboard: Option<KeyboardShortcut>, _pointer: Option<PointerButton>, )

Source§

fn format(&self, names: &ModifierNames<'_>, is_mac: bool) -> String

Source§

fn pressed(&self, input: &mut InputState) -> bool

Source§

impl Bind for PointerButton

A Bind implementation for egui’s PointerButton. Ignores keys and modifiers.

Source§

fn set( &mut self, _keyboard: Option<KeyboardShortcut>, pointer: Option<PointerButton>, )

Source§

fn format(&self, _names: &ModifierNames<'_>, _is_mac: bool) -> String

Source§

fn pressed(&self, input: &mut InputState) -> bool

Source§

impl Bind for Key

A Bind implementation for egui’s Key. Ignores modifiers.

Source§

fn set( &mut self, keyboard: Option<KeyboardShortcut>, _pointer: Option<PointerButton>, )

Source§

fn format(&self, _names: &ModifierNames<'_>, _is_mac: bool) -> String

Source§

fn pressed(&self, input: &mut InputState) -> bool

Source§

impl Bind for KeyboardShortcut

A Bind implementation for egui’s KeyboardShortcut.

Source§

fn set( &mut self, keyboard: Option<KeyboardShortcut>, _pointer: Option<PointerButton>, )

Source§

fn format(&self, names: &ModifierNames<'_>, is_mac: bool) -> String

Source§

fn pressed(&self, input: &mut InputState) -> bool

Implementors§