pub struct InputSnapshot {
pub focused: Option<ElementId>,
pub hovered: Option<ElementId>,
pub pressed: Option<ElementId>,
}Expand description
Copyable strict focus/hover/press targets for one pointer view.
hovered and pressed belong to the selected pointer ID; focused is
global to the router/window and is identical across pointer snapshots.
§Examples
use ailloli_ui_core::ElementId;
use ailloli_ui_runtime::input::InputSnapshot;
let snapshot = InputSnapshot { focused: Some(ElementId(1)), hovered: None, pressed: None };
assert_eq!(snapshot.interaction_for(ElementId(1)).focused, true);Fields§
§focused: Option<ElementId>Strict keyboard-focus owner.
hovered: Option<ElementId>Strict pointer hover target.
pressed: Option<ElementId>Strict pointer press target.
Implementations§
Source§impl InputSnapshot
Resolves snapshot targets into per-element paint interaction.
impl InputSnapshot
Resolves snapshot targets into per-element paint interaction.
Sourcepub fn interaction_for(self, id: ElementId) -> InputInteraction
pub fn interaction_for(self, id: ElementId) -> InputInteraction
Resolves strict interaction flags for id without consulting a tree.
focus_within equals strict focused here. Use
Self::interaction_for_widget_paint to include ancestor/child paint
propagation.
§Examples
use ailloli_ui_core::ElementId;
use ailloli_ui_runtime::input::InputSnapshot;
let snapshot = InputSnapshot { focused: Some(ElementId(1)), hovered: Some(ElementId(2)), pressed: None };
let interaction = snapshot.interaction_for(ElementId(2));
assert!(!interaction.focused && interaction.hovered && !interaction.pressed);Sourcepub fn interaction_for_widget_paint<A: 'static>(
self,
tree: &ElementTree<A>,
id: ElementId,
) -> InputInteraction
pub fn interaction_for_widget_paint<A: 'static>( self, tree: &ElementTree<A>, id: ElementId, ) -> InputInteraction
Interaction state for paint: walks the hit-test chain without false sibling hovers.
- Parent (e.g.
Button) hovers when the pointer hits a child (Icon). - Child hovers when the hit is on a non-flex parent (button padding).
- Hit on empty
Row/Columngaps does not hover all sibling buttons.
Focus remains strict on the focused element only.
focus_within follows stored parent links. Malformed parent cycles can
therefore inherit the nontermination behavior of ElementTree::is_ancestor_of.
§Examples
use ailloli_ui_core::ElementId;
use ailloli_ui_runtime::element::{ElementKind, ElementTree};
use ailloli_ui_runtime::input::InputSnapshot;
let mut tree = ElementTree::<()>::new();
let root = tree.create_element(ElementKind::Empty, None, None);
let child = tree.create_element(ElementKind::Empty, None, Some(root));
let interaction = InputSnapshot { focused: Some(child), hovered: None, pressed: None }
.interaction_for_widget_paint(&tree, root);
assert!(!interaction.focused && interaction.focus_within);Trait Implementations§
Source§impl Clone for InputSnapshot
impl Clone for InputSnapshot
Source§fn clone(&self) -> InputSnapshot
fn clone(&self) -> InputSnapshot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InputSnapshot
impl Debug for InputSnapshot
Source§impl Default for InputSnapshot
impl Default for InputSnapshot
Source§fn default() -> InputSnapshot
fn default() -> InputSnapshot
Source§impl PartialEq for InputSnapshot
impl PartialEq for InputSnapshot
impl Copy for InputSnapshot
impl Eq for InputSnapshot
impl StructuralPartialEq for InputSnapshot
Auto Trait Implementations§
impl Freeze for InputSnapshot
impl RefUnwindSafe for InputSnapshot
impl Send for InputSnapshot
impl Sync for InputSnapshot
impl Unpin for InputSnapshot
impl UnwindSafe for InputSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
Source§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.