|
|
@ -38,9 +38,6 @@ pub struct Response { |
|
|
|
///
|
|
|
|
/// This is sometimes smaller than [`Self::rect`] because of clipping
|
|
|
|
/// (e.g. when inside a scroll area).
|
|
|
|
///
|
|
|
|
/// The interact rect may also be slightly larger than the widget rect,
|
|
|
|
/// because egui adds half if the item spacing to make the interact rect easier to hit.
|
|
|
|
pub interact_rect: Rect, |
|
|
|
|
|
|
|
/// The senses (click and/or drag) that the widget was interested in (if any).
|
|
|
@ -59,7 +56,7 @@ pub struct Response { |
|
|
|
pub enabled: bool, |
|
|
|
|
|
|
|
// OUT:
|
|
|
|
/// The pointer is hovering above this widget.
|
|
|
|
/// The pointer is above this widget with no other blocking it.
|
|
|
|
#[doc(hidden)] |
|
|
|
pub contains_pointer: bool, |
|
|
|
|
|
|
@ -200,7 +197,10 @@ impl Response { |
|
|
|
self.clicked && self.ctx.input(|i| i.pointer.button_triple_clicked(button)) |
|
|
|
} |
|
|
|
|
|
|
|
/// `true` if there was a click *outside* this widget this frame.
|
|
|
|
/// `true` if there was a click *outside* the rect of this widget.
|
|
|
|
///
|
|
|
|
/// Clicks on widgets contained in this one counts as clicks inside this widget,
|
|
|
|
/// so that clicking a button in an area will not be considered as clicking "elsewhere" from the area.
|
|
|
|
pub fn clicked_elsewhere(&self) -> bool { |
|
|
|
// We do not use self.clicked(), because we want to catch all clicks within our frame,
|
|
|
|
// even if we aren't clickable (or even enabled).
|
|
|
@ -243,14 +243,13 @@ impl Response { |
|
|
|
self.hovered |
|
|
|
} |
|
|
|
|
|
|
|
/// Returns true if the pointer is contained by the response rect.
|
|
|
|
/// Returns true if the pointer is contained by the response rect, and no other widget is covering it.
|
|
|
|
///
|
|
|
|
/// In contrast to [`Self::hovered`], this can be `true` even if some other widget is being dragged.
|
|
|
|
/// This means it is useful for styling things like drag-and-drop targets.
|
|
|
|
/// `contains_pointer` can also be `true` for disabled widgets.
|
|
|
|
///
|
|
|
|
/// This is slightly different from [`Ui::rect_contains_pointer`] and [`Context::rect_contains_pointer`],
|
|
|
|
/// The rectangle used here is slightly larger, by half of the current item spacing.
|
|
|
|
/// This is slightly different from [`Ui::rect_contains_pointer`] and [`Context::rect_contains_pointer`], in that
|
|
|
|
/// [`Self::contains_pointer`] also checks that no other widget is covering this response rectangle.
|
|
|
|
#[inline(always)] |
|
|
|
pub fn contains_pointer(&self) -> bool { |
|
|
|