Skip to main content

SliverHitTestResult

Struct SliverHitTestResult 

Source
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>

Source

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.

Source

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>§

Source

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.

Source

pub fn release_targets(&mut self, app: &mut App)

Releases what retain_targets retained, without waiting for the checkpoint.

Source

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.

Source

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.

Source

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 to push_transform but is limited to translations, and is faster in such cases.
  • BoxHitTestResult.addWithPaintTransform, which is a public wrapper around this function for hit testing on RenderBoxs.
Source

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 to push_offset but allows general transform besides translation.
  • BoxHitTestResult.addWithPaintOffset, which is a public wrapper around this function for hit testing on RenderBoxs.
  • SliverHitTestResult.addWithAxisOffset, which is a public wrapper around this function for hit testing on RenderSlivers.
Source

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:

Trait Implementations§

Source§

impl Deref for SliverHitTestResult<'_>

Source§

type Target = HitTestResult

The resulting type after dereferencing.
Source§

fn deref(&self) -> &HitTestResult

Dereferences the value.
Source§

impl DerefMut for SliverHitTestResult<'_>

Source§

fn deref_mut(&mut self) -> &mut HitTestResult

Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>