pub struct SliverHitTestResult<'a>(/* private fields */);Expand description
The result of performing a hit test on RenderSlivers.
A view over a HitTestResult: Dart’s SliverHitTestResult.wrap. Dart’s bare
SliverHitTestResult() constructor is wrap over a fresh HitTestResult.
Implementations§
Source§impl<'a> SliverHitTestResult<'a>
impl<'a> SliverHitTestResult<'a>
Sourcepub fn wrap(result: &'a mut HitTestResult) -> SliverHitTestResult<'a>
pub fn wrap(result: &'a mut HitTestResult) -> SliverHitTestResult<'a>
Wraps result to create a SliverHitTestResult that shares its path.
This is used by render objects that adapt between the sliver world and the non-sliver world.
Sourcepub fn add_with_axis_offset(
&mut self,
paint_offset: Option<Offset>,
main_axis_offset: f64,
cross_axis_offset: f64,
main_axis_position: f64,
cross_axis_position: f64,
hit_test: impl FnOnce(&mut SliverHitTestResult<'_>, f64, f64) -> bool,
) -> bool
pub fn add_with_axis_offset( &mut self, paint_offset: Option<Offset>, main_axis_offset: f64, cross_axis_offset: f64, main_axis_position: f64, cross_axis_position: f64, hit_test: impl FnOnce(&mut SliverHitTestResult<'_>, f64, f64) -> bool, ) -> bool
Transforms main_axis_position and cross_axis_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 positions as arguments.
For the transform main_axis_offset is subtracted from main_axis_position and
cross_axis_offset is subtracted from cross_axis_position.
The paint_offset describes how the paint position of a point painted at the provided
main_axis_position and cross_axis_position would change after main_axis_offset and
cross_axis_offset have been applied. It is used to properly convert pointer events to
the local coordinate system of the event receiver.
The paint_offset may be None if main_axis_offset and cross_axis_offset are both
zero.
The function returns the return value of hit_test.
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.