Skip to main content

AdaptEventCx

Struct AdaptEventCx 

Source
pub struct AdaptEventCx<'a: 'b, 'b> { /* private fields */ }
Expand description

An EventCx with embedded Id and input data

NOTE: this is a temporary design: it may be expanded or integrated with EventCx in the future.

Implementations§

Source§

impl<'a: 'b, 'b> AdaptEventCx<'a, 'b>

Source

pub fn new(cx: &'b mut EventCx<'a>, id: Id) -> Self

Construct

Source

pub fn id(&self) -> Id

Get the widget’s identifier

Source

pub fn is_disabled(&self) -> bool

Check whether this widget is disabled

Source

pub fn set_disabled(&mut self, state: bool)

Set/unset disabled status for this widget

Source

pub fn request_timer(&mut self, handle: TimerHandle, delay: Duration)

Schedule a timed update

Widget updates may be used for delayed action. For animation, prefer to use Draw::animate or Self::request_frame_timer.

This widget will receive an update for timer handle at approximately time = now + delay (or possibly a little later due to frame-rate limiters and processing time).

Requesting an update with delay == 0 is valid except from a timer handler where it may cause an infinite loop.

Multiple timer requests with the same id and handle are merged (see TimerHandle documentation).

Source

pub fn request_frame_timer(&mut self, handle: TimerHandle)

Schedule a frame timer update

Widget id will receive Event::Timer with this handle either before or soon after the next frame is drawn.

This may be useful for animations which mutate widget state. Animations which don’t mutate widget state may use Draw::animate instead.

It is expected that handle.earliest() == true (style guide).

Methods from Deref<Target = EventState>§

Source

pub fn has_input_focus(&self, w_id: &Id) -> Option<bool>

Get whether this widget has input focus

Return values:

  • None if the widget does not have selection focus
  • Some(false) if the widget has selection focus but not keyboard or IME focus
  • Some(true) if the widget has keyboard and/or IME focus
Source

pub fn modifiers(&self) -> ModifiersState

Get the current modifier state

Source

pub fn has_nav_focus(&self, w_id: &Id) -> bool

Get whether this widget has navigation focus

Source

pub fn nav_focus(&self) -> Option<&Id>

Get the current navigation focus, if any

This is the widget selected by navigating the UI with the Tab key.

Note: changing navigation focus (e.g. via EventCx::clear_nav_focus, EventCx::request_nav_focus or EventCx::next_nav_focus) does not immediately affect the result of this method.

Source

pub fn is_depressed(&self, w_id: &Id) -> bool

Check whether the given widget is visually depressed

Source

pub fn is_under_mouse(&self, w_id: &Id) -> bool

Get whether the widget is under the mouse pointer

Source

pub fn any_grab_on(&self, id: &Id) -> bool

Returns true if there is a mouse or touch grab on id or any descendant of id

Source

pub fn press_velocity(&self, source: PressSource) -> Option<Vec2>

Get velocity of the mouse pointer or a touch

The velocity is calculated at the time this method is called using existing samples of motion.

Where the source is a mouse this always succeeds. For touch events this requires an active grab and is not guaranteed to succeed; currently only a limited number of presses with mode GrabMode::Grab are tracked for velocity.

Source

pub fn platform(&self) -> Platform

Get the platform

Source

pub fn window_has_focus(&self) -> bool

True when the window has focus

Source

pub fn is_disabled(&self, w_id: &Id) -> bool

Check whether a widget is disabled

A widget is disabled if any ancestor is.

Source

pub fn config(&self) -> &WindowConfig

Access configuration data

All widgets will be reconfigured if configuration data changes.

Source

pub fn config_enable_pan(&self, source: PressSource) -> bool

Is mouse panning enabled?

Source

pub fn config_enable_mouse_text_pan(&self) -> bool

Is mouse text panning enabled?

Source

pub fn config_test_pan_thresh(&self, dist: Offset) -> bool

Test pan threshold against config, adjusted for scale factor

Returns true when dist is large enough to switch to pan mode.

Trait Implementations§

Source§

impl<'a: 'b, 'b> Deref for AdaptEventCx<'a, 'b>

Source§

type Target = &'b mut EventCx<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a: 'b, 'b> DerefMut for AdaptEventCx<'a, 'b>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a, 'b> !RefUnwindSafe for AdaptEventCx<'a, 'b>

§

impl<'a, 'b> !Send for AdaptEventCx<'a, 'b>

§

impl<'a, 'b> !Sync for AdaptEventCx<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for AdaptEventCx<'a, 'b>

§

impl<'a, 'b> Freeze for AdaptEventCx<'a, 'b>

§

impl<'a, 'b> Unpin for AdaptEventCx<'a, 'b>

§

impl<'a, 'b> UnsafeUnpin for AdaptEventCx<'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<S, T> Cast<T> for S
where T: Conv<S>,

Source§

fn cast(self) -> T

Cast from Self to T Read more
Source§

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

Try converting from Self to T Read more
Source§

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

Source§

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

Try approximate conversion from Self to T Read more
Source§

fn cast_approx(self) -> T

Cast approximately from Self to T Read more
Source§

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

Source§

fn cast_trunc(self) -> T

Cast to integer, truncating Read more
Source§

fn cast_nearest(self) -> T

Cast to the nearest integer Read more
Source§

fn cast_floor(self) -> T

Cast the floor to an integer Read more
Source§

fn cast_ceil(self) -> T

Cast the ceiling to an integer Read more
Source§

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

Try converting to integer with truncation Read more
Source§

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

Try converting to the nearest integer Read more
Source§

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

Try converting the floor to an integer Read more
Source§

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

Try convert the ceiling to an integer Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

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

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

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

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

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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