pub trait ElementCursorState {
// Required method
fn is_hovered_with_margins(
&self,
id: ElementId,
margin_left: f32,
margin_top: f32,
margin_right: f32,
margin_bottom: f32,
) -> bool;
// Provided methods
fn is_hovered_with_margin(&self, id: ElementId, margin: f32) -> bool { ... }
fn is_hovered_with_axis_margin(
&self,
id: ElementId,
horizontal: f32,
vertical: f32,
) -> bool { ... }
fn is_hovered(&self, id: ElementId) -> bool { ... }
}Expand description
Query whether the cursor is over a layout element.
Implementors resolve the element’s bounding box and compare it against the
current cursor position. Returns false when the element is unknown.
§Blanket implementation
CotisApp implements this trait when:
Renderer: RenderCompatibleWith<Manager> + MouseProviderManager: LayoutManagerCompatible<Renderer> + ElementBoundingBox
Required Methods§
Sourcefn is_hovered_with_margins(
&self,
id: ElementId,
margin_left: f32,
margin_top: f32,
margin_right: f32,
margin_bottom: f32,
) -> bool
fn is_hovered_with_margins( &self, id: ElementId, margin_left: f32, margin_top: f32, margin_right: f32, margin_bottom: f32, ) -> bool
Per-edge margins: left, top, right, bottom.
Uses cursor_in_rect_with_margins against the element’s layout bounding box.
Provided Methods§
Sourcefn is_hovered_with_margin(&self, id: ElementId, margin: f32) -> bool
fn is_hovered_with_margin(&self, id: ElementId, margin: f32) -> bool
Same margin on every side (positive expands the hover region outward).
Sourcefn is_hovered_with_axis_margin(
&self,
id: ElementId,
horizontal: f32,
vertical: f32,
) -> bool
fn is_hovered_with_axis_margin( &self, id: ElementId, horizontal: f32, vertical: f32, ) -> bool
Horizontal margin applied to left and right; vertical margin to top and bottom.
Sourcefn is_hovered(&self, id: ElementId) -> bool
fn is_hovered(&self, id: ElementId) -> bool
Returns whether the cursor is inside the element’s bounding box with zero margins.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".