Skip to main content

BoxHitTestResult

Struct BoxHitTestResult 

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

Source

pub fn wrap(result: &'a mut HitTestResult) -> BoxHitTestResult<'a>

Wraps result to create a BoxHitTestResult that shares its path.

Source

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.

Source

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.

Source

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.

Source

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

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 BoxHitTestResult<'_>

Source§

type Target = HitTestResult

The resulting type after dereferencing.
Source§

fn deref(&self) -> &HitTestResult

Dereferences the value.
Source§

impl DerefMut for BoxHitTestResult<'_>

Source§

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

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for BoxHitTestResult<'a>

§

impl<'a> !Send for BoxHitTestResult<'a>

§

impl<'a> !Sync for BoxHitTestResult<'a>

§

impl<'a> !UnwindSafe for BoxHitTestResult<'a>

§

impl<'a> Freeze for BoxHitTestResult<'a>

§

impl<'a> Unpin for BoxHitTestResult<'a>

§

impl<'a> UnsafeUnpin for BoxHitTestResult<'a>

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>