Skip to main content

WidgetResponse

Struct WidgetResponse 

Source
pub struct WidgetResponse {
Show 21 fields pub id: WidgetId, pub rect: WidgetRect, pub sense: Sense, pub hovered: bool, pub hover_started: bool, pub hover_ended: bool, pub clicked: bool, pub double_clicked: bool, pub triple_clicked: bool, pub right_clicked: bool, pub middle_clicked: bool, pub drag_started: bool, pub dragged: bool, pub drag_stopped: bool, pub drag_delta: (f64, f64), pub drag_total: (f64, f64), pub has_focus: bool, pub gained_focus: bool, pub lost_focus: bool, pub changed: bool, pub enabled: bool,
}
Expand description

Unified response from widget interaction

Every widget should return a WidgetResponse containing information about user interactions with that widget during the current frame.

Fields§

§id: WidgetId

Widget identifier

§rect: WidgetRect

Widget’s bounding rectangle

§sense: Sense

What interactions this widget senses

§hovered: bool

Mouse is hovering over widget

§hover_started: bool

Mouse entered widget this frame

§hover_ended: bool

Mouse left widget this frame

§clicked: bool

Left mouse button clicked this frame

§double_clicked: bool

Left mouse button double-clicked this frame

§triple_clicked: bool

Left mouse button triple-clicked this frame

§right_clicked: bool

Right mouse button clicked this frame

§middle_clicked: bool

Middle mouse button clicked this frame

§drag_started: bool

Drag operation started this frame

§dragged: bool

Widget is currently being dragged

§drag_stopped: bool

Drag operation ended this frame

§drag_delta: (f64, f64)

Drag delta since last frame

§drag_total: (f64, f64)

Total drag delta since drag started

§has_focus: bool

Widget has keyboard focus

§gained_focus: bool

Widget gained focus this frame

§lost_focus: bool

Widget lost focus this frame

§changed: bool

Underlying value changed

§enabled: bool

Widget is enabled (not disabled/grayed)

Implementations§

Source§

impl WidgetResponse

Source

pub fn new(id: WidgetId, rect: WidgetRect, sense: Sense) -> Self

Create new response for widget

Source

pub fn with_hover(self, hovered: bool) -> Self

Set hover state

Source

pub fn with_click(self) -> Self

Set clicked state

Source

pub fn with_focus(self, has_focus: bool) -> Self

Set focus state

Source

pub fn with_changed(self) -> Self

Mark as changed

Source

pub fn disabled(self) -> Self

Mark as disabled

Source§

impl WidgetResponse

Source

pub fn any_click(&self) -> bool

Check if any click occurred (left, right, or middle)

Source

pub fn interacted(&self) -> bool

Check if widget was interacted with this frame (click, drag start, or gained focus)

Source

pub fn is_active(&self) -> bool

Check if widget is active (being dragged or has focus)

Source

pub fn is_pointer_over(&self) -> bool

Check if pointer is over widget or dragging it

Source§

impl WidgetResponse

Source

pub fn union(self, other: WidgetResponse) -> WidgetResponse

Combine two responses (logical OR of interaction states)

Uses the rect and id of self.

Trait Implementations§

Source§

impl BitOr for WidgetResponse

Source§

fn bitor(self, rhs: Self) -> Self::Output

Combine two responses using the | operator (equivalent to union)

Source§

type Output = WidgetResponse

The resulting type after applying the | operator.
Source§

impl Clone for WidgetResponse

Source§

fn clone(&self) -> WidgetResponse

Returns a duplicate 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 WidgetResponse

Source§

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

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

impl Default for WidgetResponse

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