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: WidgetIdWidget identifier
rect: WidgetRectWidget’s bounding rectangle
sense: SenseWhat interactions this widget senses
hovered: boolMouse is hovering over widget
hover_started: boolMouse entered widget this frame
hover_ended: boolMouse left widget this frame
clicked: boolLeft mouse button clicked this frame
double_clicked: boolLeft mouse button double-clicked this frame
triple_clicked: boolLeft mouse button triple-clicked this frame
right_clicked: boolRight mouse button clicked this frame
middle_clicked: boolMiddle mouse button clicked this frame
drag_started: boolDrag operation started this frame
dragged: boolWidget is currently being dragged
drag_stopped: boolDrag 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: boolWidget has keyboard focus
gained_focus: boolWidget gained focus this frame
lost_focus: boolWidget lost focus this frame
changed: boolUnderlying value changed
enabled: boolWidget is enabled (not disabled/grayed)
Implementations§
Source§impl WidgetResponse
impl WidgetResponse
Sourcepub fn new(id: WidgetId, rect: WidgetRect, sense: Sense) -> Self
pub fn new(id: WidgetId, rect: WidgetRect, sense: Sense) -> Self
Create new response for widget
Sourcepub fn with_hover(self, hovered: bool) -> Self
pub fn with_hover(self, hovered: bool) -> Self
Set hover state
Sourcepub fn with_click(self) -> Self
pub fn with_click(self) -> Self
Set clicked state
Sourcepub fn with_focus(self, has_focus: bool) -> Self
pub fn with_focus(self, has_focus: bool) -> Self
Set focus state
Sourcepub fn with_changed(self) -> Self
pub fn with_changed(self) -> Self
Mark as changed
Source§impl WidgetResponse
impl WidgetResponse
Sourcepub fn interacted(&self) -> bool
pub fn interacted(&self) -> bool
Check if widget was interacted with this frame (click, drag start, or gained focus)
Sourcepub fn is_pointer_over(&self) -> bool
pub fn is_pointer_over(&self) -> bool
Check if pointer is over widget or dragging it
Source§impl WidgetResponse
impl WidgetResponse
Sourcepub fn union(self, other: WidgetResponse) -> WidgetResponse
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
impl BitOr for WidgetResponse
Source§impl Clone for WidgetResponse
impl Clone for WidgetResponse
Source§fn clone(&self) -> WidgetResponse
fn clone(&self) -> WidgetResponse
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more