findObjectAt<T extends GraphObject> method

T? findObjectAt<T extends GraphObject>(
  1. Point p, [
  2. T? navig(
    1. GraphObject
    )?,
  3. bool pred(
    1. T
    )?
])

Find the front-most GraphObject at the given point in document coordinates.

If Layer#visible is false, this method will not find any objects in that layer. However, Layer#opacity does not affect this method.

Example usage:

// Returns the top-most object that is a selectable Part, or null if there isn't one
myDiagram.findObjectAt(
  myDiagram.lastInput.documentPoint,
  // Navigation function
  x => x.part,
  // Because of the navigation function, x will always be a Part.
  x => x.canSelect()
);

@param {Point} p A Point in document coordinates. @param {function(GraphObject):GraphObject | null=} navig A function taking a GraphObject and returning a GraphObject, defaulting to the identity. @param {function(GraphObject):boolean | null=} pred A function taking the GraphObject returned by navig and returning true if that object should be returned, defaulting to a predicate that always returns true. @return {GraphObject} The first GraphObject returned by the navig function and satisfying the pred function that is at the point p, in Z-order from front to back, or else null if nothing is found. @see #findObjectsAt @see #findObjectsIn @see #findObjectsNear @see #findPartAt

Implementation

T? findObjectAt<T extends _i3.GraphObject>(
  _i3.Point p, [
  T? Function(_i3.GraphObject)? navig,
  _i2.bool Function(T)? pred,
]) =>
    _i4.callMethod(
      this,
      'findObjectAt',
      [
        p,
        navig == null
            ? _i5.undefined
            : _i4.allowInterop((p0) => () => navig(p0) ?? _i5.undefined),
        pred == null ? _i5.undefined : _i4.allowInterop(pred),
      ],
    );