Struct egui::Response [−][src]
The result of adding a widget to a Ui
.
A Response
lets you know whether or not a widget is being hovered, clicked or dragged.
It also lets you easily show a tooltip on hover.
Whenever something gets added to a Ui
, a Response
object is returned.
[ui.add
] returns a Response
, as does [ui.button
], and all similar shortcuts.
Fields
ctx: CtxRef
Used for optionally showing a tooltip and checking for more interactions.
layer_id: LayerId
Which layer the widget is part of.
id: Id
The Id
of the widget/area this response pertains.
rect: Rect
The area of the screen we are talking about.
sense: Sense
The senses (click and/or drag) that the widget was interested in (if any).
Implementations
impl Response
[src]
pub fn clicked(&self) -> bool
[src]
Returns true if this widget was clicked this frame by the primary button.
pub fn secondary_clicked(&self) -> bool
[src]
Returns true if this widget was clicked this frame by the secondary mouse button (e.g. the right mouse button).
pub fn middle_clicked(&self) -> bool
[src]
Returns true if this widget was clicked this frame by the middle mouse button.
pub fn double_clicked(&self) -> bool
[src]
Returns true if this widget was double-clicked this frame by the primary button.
pub fn enabled(&self) -> bool
[src]
Was the widget enabled? If false, there was no interaction attempted and the widget should be drawn in a gray disabled look.
pub fn hovered(&self) -> bool
[src]
The pointer is hovering above this widget or the widget was clicked/tapped this frame.
pub fn has_kb_focus(&self) -> bool
[src]
This widget has the keyboard focus (i.e. is receiving key presses).
pub fn lost_kb_focus(&self) -> bool
[src]
The widget had keyboard focus and lost it, perhaps because the user pressed enter. If you want to do an action when a user presses enter in a text field, use this.
if ui.text_edit_singleline(&mut my_text).lost_kb_focus() { do_request(&my_text); }
pub fn dragged(&self) -> bool
[src]
The widgets is being dragged.
To find out which button(s), query crate::PointerState::button_down
(ui.input().pointer.button_down(…)
).
pub fn drag_started(&self) -> bool
[src]
Did a drag on this widgets begin this frame?
pub fn drag_released(&self) -> bool
[src]
The widget was being dragged, but now it has been released.
pub fn clicked_by(&self, button: PointerButton) -> bool
[src]
Returns true if this widget was clicked this frame by the given button.
pub fn double_clicked_by(&self, button: PointerButton) -> bool
[src]
Returns true if this widget was double-clicked this frame by the given button.
pub fn interact_pointer_pos(&self) -> Option<Pos2>
[src]
Where the pointer (mouse/touch) were when when this widget was clicked or dragged.
None
if the widget is not being interacted with.
pub fn is_pointer_button_down_on(&self) -> bool
[src]
Is the pointer button currently down on this widget? This is true if the pointer is pressing down or dragging a widget
pub fn changed(&self) -> bool
[src]
What the underlying data changed?
e.g. the slider was dragged, text was entered in a TextEdit
etc.
Always false
for something like a Button
.
Can sometimes be true
even though the data didn’t changed
(e.g. if the user entered a character and erased it the same frame).
pub fn mark_changed(&mut self)
[src]
Report the data shown by this widget changed.
This must be called by widgets that represent some mutable data, e.g. checkboxes, sliders etc.
pub fn on_hover_ui(self, add_contents: impl FnOnce(&mut Ui)) -> Self
[src]
Show this UI if the item was hovered (i.e. a tooltip). If you call this multiple times the tooltips will stack underneath the previous ones.
pub fn on_hover_text(self, text: impl Into<String>) -> Self
[src]
Show this text if the item was hovered (i.e. a tooltip). If you call this multiple times the tooltips will stack underneath the previous ones.
pub fn tooltip_text(self, text: impl Into<String>) -> Self
[src]
Deprecated 2020-10-01: use on_hover_text
instead.
pub fn interact(&self, sense: Sense) -> Self
[src]
Check for more interactions (e.g. sense clicks on a Response
returned from a label).
let response = ui.label("hello"); assert!(!response.clicked()); // labels don't sense clicks let response = response.interact(egui::Sense::click()); if response.clicked() { /* … */ }
pub fn scroll_to_me(&self, align: Align)
[src]
Move the scroll to this UI with the specified alignment.
egui::ScrollArea::auto_sized().show(ui, |ui| { for i in 0..1000 { let response = ui.button(format!("Button {}", i)); if response.clicked() { response.scroll_to_me(Align::Center); } } });
impl Response
[src]
pub fn union(&self, other: Self) -> Self
[src]
A logical “or” operation.
For instance a.union(b).hovered
means “was either a or b hovered?”.
Trait Implementations
impl BitOr<Response> for Response
[src]
To summarize the response from many widgets you can use this pattern:
use egui::*; fn draw_vec2(ui: &mut Ui, v: &mut Vec2) -> Response { ui.add(DragValue::f32(&mut v.x)) | ui.add(DragValue::f32(&mut v.y)) }
Now draw_vec2(ui, foo).hovered
is true if either DragValue
were hovered.
type Output = Self
The resulting type after applying the |
operator.
fn bitor(self, rhs: Self) -> Self
[src]
impl BitOrAssign<Response> for Response
[src]
To summarize the response from many widgets you can use this pattern:
let mut response = ui.add(widget_a); response |= ui.add(widget_b); response |= ui.add(widget_c); if response.hovered() { ui.label("You hovered at least one of the widgets"); }
fn bitor_assign(&mut self, rhs: Self)
[src]
impl Clone for Response
[src]
impl Debug for Response
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl !UnwindSafe for Response
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,