pub struct BoxHitTestResult<'a>(/* private fields */);Expand description
The result of performing a hit test on RenderBoxes.
A view over a HitTestResult: Dart’s BoxHitTestResult.wrap. Dart’s bare
BoxHitTestResult() constructor is wrap over a fresh HitTestResult.
Implementations§
Source§impl<'a> BoxHitTestResult<'a>
impl<'a> BoxHitTestResult<'a>
Sourcepub fn wrap(result: &'a mut HitTestResult) -> BoxHitTestResult<'a>
pub fn wrap(result: &'a mut HitTestResult) -> BoxHitTestResult<'a>
Wraps result to create a BoxHitTestResult that shares its path.
Sourcepub fn add_with_paint_transform(
&mut self,
transform: Option<Matrix4>,
position: Offset,
hit_test: impl FnOnce(&mut BoxHitTestResult<'_>, Offset) -> bool,
) -> bool
pub fn add_with_paint_transform( &mut self, transform: Option<Matrix4>, position: Offset, hit_test: impl FnOnce(&mut BoxHitTestResult<'_>, Offset) -> bool, ) -> bool
Transforms position to the local coordinate system of a child for hit-testing the
child.
The actual hit testing of the child needs to be implemented in the provided hit_test
callback, which is invoked with the transformed position as argument.
The provided paint transform (which describes the transform from the child to the
parent in 3D) is processed by remove_perspective_transform to remove the
perspective component and inverted before it is used to transform position from the
coordinate system of the parent to the system of the child.
If transform is None it will be treated as the identity transform and position is
provided to the hit_test callback as-is. If transform cannot be inverted, the
hit_test callback is not invoked and false is returned.
Sourcepub fn add_with_paint_offset(
&mut self,
offset: Option<Offset>,
position: Offset,
hit_test: impl FnOnce(&mut BoxHitTestResult<'_>, Offset) -> bool,
) -> bool
pub fn add_with_paint_offset( &mut self, offset: Option<Offset>, position: Offset, hit_test: impl FnOnce(&mut BoxHitTestResult<'_>, Offset) -> bool, ) -> bool
Convenience method for hit testing children, that are translated by an Offset.
The actual hit testing of the child needs to be implemented in the provided hit_test
callback, which is invoked with the transformed position as argument.
Sourcepub fn add_with_raw_transform(
&mut self,
transform: Option<Matrix4>,
position: Offset,
hit_test: impl FnOnce(&mut BoxHitTestResult<'_>, Offset) -> bool,
) -> bool
pub fn add_with_raw_transform( &mut self, transform: Option<Matrix4>, position: Offset, hit_test: impl FnOnce(&mut BoxHitTestResult<'_>, Offset) -> bool, ) -> bool
Transforms position to the local coordinate system of a child for hit-testing the
child.
Unlike add_with_paint_transform, the provided
transform is used as-is to transform position: it must describe the transform from
the parent to the child.
Sourcepub fn add_with_out_of_band_position(
&mut self,
paint_offset: Option<Offset>,
paint_transform: Option<Matrix4>,
raw_transform: Option<Matrix4>,
hit_test: impl FnOnce(&mut BoxHitTestResult<'_>) -> bool,
) -> bool
pub fn add_with_out_of_band_position( &mut self, paint_offset: Option<Offset>, paint_transform: Option<Matrix4>, raw_transform: Option<Matrix4>, hit_test: impl FnOnce(&mut BoxHitTestResult<'_>) -> bool, ) -> bool
Pass-through method for adding a hit test while manually managing the position transformation logic.
Exactly one of paint_offset, paint_transform, or raw_transform must be given.
Methods from Deref<Target = HitTestResult>§
Sourcepub fn retain_targets(&mut self, app: &mut App)
pub fn retain_targets(&mut self, app: &mut App)
Retains every object on the path, for a result kept past this turn (Dart keeps them alive
by holding the path). The retained handles live in the result: dropping it releases them
at the next checkpoint, release_targets releases them now.
Sourcepub fn release_targets(&mut self, app: &mut App)
pub fn release_targets(&mut self, app: &mut App)
Releases what retain_targets retained, without waiting for the
checkpoint.
Sourcepub fn path(&self) -> &[HitTestEntry]
pub fn path(&self) -> &[HitTestEntry]
An unmodifiable list of HitTestEntry objects recorded during the hit test.
The first entry in the path is the most specific, typically the one at the leaf of tree being hit tested. Event propagation starts with the most specific (i.e., first) entry and proceeds in order through the path.
Sourcepub fn add(&mut self, entry: HitTestEntry)
pub fn add(&mut self, entry: HitTestEntry)
Add a HitTestEntry to the path.
The new entry is added at the end of the path, which means entries should be added in order from most specific to least specific, typically during an upward walk of the tree being hit tested.
Sourcepub fn push_transform(&mut self, transform: Matrix)
pub fn push_transform(&mut self, transform: Matrix)
Pushes a new transform matrix that is to be applied to all future
HitTestEntrys added via add until it is removed via pop_transform.
This method is only to be used by subclasses, which must provide
coordinate space specific public wrappers around this function for their
users (see BoxHitTestResult.addWithPaintTransform for such an example).
The provided transform matrix should describe how to transform
PointerEvents from the coordinate space of the method caller to the
coordinate space of its children. In most cases transform is derived
from running the inverted result of RenderObject.applyPaintTransform
through remove_perspective_transform to remove
the perspective component.
If the provided transform is a translation matrix, it is much faster
to use push_offset with the translation offset instead.
HitTestables need to call this method indirectly through a convenience
method defined on a subclass before hit testing a child that does not
have the same origin as the parent. After hit testing the child,
pop_transform has to be called to remove the child-specific transform.
See also:
push_offset, which is similar topush_transformbut is limited to translations, and is faster in such cases.BoxHitTestResult.addWithPaintTransform, which is a public wrapper around this function for hit testing onRenderBoxs.
Sourcepub fn push_offset(&mut self, offset: Offset)
pub fn push_offset(&mut self, offset: Offset)
Pushes a new translation offset that is to be applied to all future
HitTestEntrys added via add until it is removed via pop_transform.
This method is only to be used by subclasses, which must provide
coordinate space specific public wrappers around this function for their
users (see BoxHitTestResult.addWithPaintOffset for such an example).
The provided offset should describe how to transform PointerEvents from
the coordinate space of the method caller to the coordinate space of its
children. Usually offset is the inverse of the offset of the child
relative to the parent.
HitTestables need to call this method indirectly through a convenience
method defined on a subclass before hit testing a child that does not
have the same origin as the parent. After hit testing the child,
pop_transform has to be called to remove the child-specific transform.
See also:
push_transform, which is similar topush_offsetbut allows general transform besides translation.BoxHitTestResult.addWithPaintOffset, which is a public wrapper around this function for hit testing onRenderBoxs.SliverHitTestResult.addWithAxisOffset, which is a public wrapper around this function for hit testing onRenderSlivers.
Sourcepub fn pop_transform(&mut self)
pub fn pop_transform(&mut self)
Removes the last transform added via push_transform or push_offset.
This method is only to be used by subclasses, which must provide
coordinate space specific public wrappers around this function for their
users (see BoxHitTestResult.addWithPaintTransform for such an example).
This method must be called after hit testing is done on a child that
required a call to push_transform or push_offset.
See also:
push_transformandpush_offset, which describes the use case of this function pair in more details.