Enum kas::event::Command

source ·
#[non_exhaustive]
pub enum Command {
Show 63 variants Escape, Activate, Enter, Space, Tab, ViewUp, ViewDown, Left, Right, Up, Down, WordLeft, WordRight, Home, End, DocHome, DocEnd, PageUp, PageDown, Snapshot, ScrollLock, Pause, Insert, Delete, DelBack, DelWord, DelWordBack, Deselect, SelectAll, Find, FindReplace, FindNext, FindPrevious, Bold, Italic, Underline, Link, Cut, Copy, Paste, Undo, Redo, New, Open, Save, Print, NavNext, NavPrevious, NavParent, NavDown, TabNew, TabNext, TabPrevious, Help, Rename, Refresh, Debug, SpellCheck, ContextMenu, Menu, Fullscreen, Close, Exit,
}
Expand description

Command input (Event::Command)

Command events are mostly produced as a result of OS-specific keyboard bindings; for example, Command::Copy is produced by pressing Command+C on MacOS or Ctrl+C on other platforms. See crate::event::config::Shortcuts for more on these bindings.

A Command event does not necessarily come from keyboard input; for example some menu widgets send Command::Activate to trigger an entry as a result of mouse input.

Most Command entries represent an action (such as Copy or FindNext) but some represent an important key whose action may be context-dependent (e.g. Escape, Space).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Escape

Escape key

Each press of this key should somehow relax control. It is expected that widgets receiving this key repeatedly eventually (soon) have no more use for this themselves and return it via Unused.

This is in some cases remapped to Command::Deselect.

§

Activate

Programmatic activation

A synthetic event to activate widgets. Consider matching Command::is_activate or using using Event::on_activate instead for generally applicable activation.

§

Enter

Return / enter key

This may insert a line-break or may activate something.

§

Space

Space bar key

§

Tab

Tab key

This key is used to insert (horizontal) tabulators as well as to navigate focus (in reverse when combined with Shift).

This is usually not sent to widgets but instead used for navigation.

§

ViewUp

Move view up without affecting selection

§

ViewDown

Move view down without affecting selection

§

Left

Move left

§

Right

Move right

§

Up

Move up

§

Down

Move down

§

WordLeft

Move left one word

§

WordRight

Move right one word

§

Home

Move to start (of the line)

§

End

Move to end (of the line)

§

DocHome

Move to start of the document

§

DocEnd

Move to end of the document

§

PageUp

Move up a page

§

PageDown

Move down a page

§

Snapshot

Capture a screenshot

§

ScrollLock

Lock output of screen

§

Pause

Pause key

§

Insert

Insert key

§

Delete

Delete forwards

§

DelBack

Delete backwards (Backspace key)

§

DelWord

Delete forwards one word

§

DelWordBack

Delete backwards one word

§

Deselect

Clear any selections

§

SelectAll

Select all contents

§

Find

Find (start)

§

FindReplace

Find and replace (start)

§

FindNext

Find next

§

FindPrevious

Find previous

§

Bold

Make text bold

§

Italic

Make text italic

§

Underline

Underline text

Insert a link

§

Cut

Copy to clipboard and clear

§

Copy

Copy to clipboard

§

Paste

Copy from clipboard

§

Undo

Undo the last action

§

Redo

Redo the last undone action

§

New

New document

§

Open

Open document

§

Save

Save document

§

Print

Print document

§

NavNext

Navigate forwards one page/item

§

NavPrevious

Navigate backwards one page/item

§

NavParent

Navigate to the parent item

May be used to browse “up” to a parent directory.

§

NavDown

Navigate “down”

This is an opposite to NavParent, and will mostly not be used.

§

TabNew

Open a new tab

§

TabNext

Navigate to next tab

§

TabPrevious

Navigate to previous tab

§

Help

Show help

§

Rename

Rename

§

Refresh

Refresh

§

Debug

Debug

§

SpellCheck

Spell-check tool

§

ContextMenu

Open the context menu

§

Menu

Open or activate the application menu / menubar

§

Fullscreen

Make view fullscreen

§

Close

Close window/tab/popup

§

Exit

Exit program (e.g. Ctrl+Q)

Implementations§

source§

impl Command

source

pub fn new(key: &Key) -> Option<Command>

Try constructing from a winit::keyboard::Key

source

pub fn is_activate(self) -> bool

True for “activation” commands

This matches:

source

pub fn suitable_for_sel_focus(self) -> bool

Convert to selection-focus command

Certain limited commands may be sent to widgets with selection focus but not character or navigation focus.

source

pub fn as_direction(self) -> Option<Direction>

Convert arrow keys to a direction

Trait Implementations§

source§

impl Clone for Command

source§

fn clone(&self) -> Command

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Command

source§

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

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

impl Hash for Command

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Command

source§

fn cmp(&self, other: &Command) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Command

source§

fn eq(&self, other: &Command) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Command

source§

fn partial_cmp(&self, other: &Command) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Command

source§

impl Eq for Command

source§

impl StructuralEq for Command

source§

impl StructuralPartialEq for Command

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
§

impl<S, T> Cast<T> for S
where T: Conv<S>,

§

fn cast(self) -> T

Cast from Self to T Read more
§

fn try_cast(self) -> Result<T, Error>

Try converting from Self to T Read more
§

impl<S, T> CastApprox<T> for S
where T: ConvApprox<S>,

§

fn try_cast_approx(self) -> Result<T, Error>

Try approximate conversion from Self to T Read more
§

fn cast_approx(self) -> T

Cast approximately from Self to T Read more
§

impl<S, T> CastFloat<T> for S
where T: ConvFloat<S>,

§

fn cast_trunc(self) -> T

Cast to integer, truncating Read more
§

fn cast_nearest(self) -> T

Cast to the nearest integer Read more
§

fn cast_floor(self) -> T

Cast the floor to an integer Read more
§

fn cast_ceil(self) -> T

Cast the ceiling to an integer Read more
§

fn try_cast_trunc(self) -> Result<T, Error>

Try converting to integer with truncation Read more
§

fn try_cast_nearest(self) -> Result<T, Error>

Try converting to the nearest integer Read more
§

fn try_cast_floor(self) -> Result<T, Error>

Try converting the floor to an integer Read more
§

fn try_cast_ceil(self) -> Result<T, Error>

Try convert the ceiling to an integer Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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>,

§

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>,

§

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<N> NodeTrait for N
where N: Copy + Ord + Hash,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSync for T
where T: Sync,