implementAsBlocking static method

NSDraggingSource implementAsBlocking({
  1. required NSDragOperation draggingSession_sourceOperationMaskForDraggingContext_(
    1. NSDraggingSession,
    2. NSDraggingContext
    ),
  2. void draggingSession_willBeginAtPoint_(
    1. NSDraggingSession,
    2. NSPoint
    )?,
  3. void draggingSession_movedToPoint_(
    1. NSDraggingSession,
    2. NSPoint
    )?,
  4. void draggingSession_endedAtPoint_operation_(
    1. NSDraggingSession,
    2. NSPoint,
    3. NSDragOperation
    )?,
  5. bool ignoreModifierKeysForDraggingSession_(
    1. NSDraggingSession
    )?,
  6. bool $keepIsolateAlive = true,
})

Builds an object that implements the NSDraggingSource protocol. To implement multiple protocols, use addToBuilder or objc.ObjCProtocolBuilder directly. All methods that can be implemented as blocking listeners will be.

If $keepIsolateAlive is true, this protocol will keep this isolate alive until it is garbage collected by both Dart and ObjC.

Implementation

static NSDraggingSource implementAsBlocking({
  required NSDragOperation Function(NSDraggingSession, NSDraggingContext)
  draggingSession_sourceOperationMaskForDraggingContext_,
  void Function(NSDraggingSession, NSPoint)?
  draggingSession_willBeginAtPoint_,
  void Function(NSDraggingSession, NSPoint)? draggingSession_movedToPoint_,
  void Function(NSDraggingSession, NSPoint, NSDragOperation)?
  draggingSession_endedAtPoint_operation_,
  bool Function(NSDraggingSession)? ignoreModifierKeysForDraggingSession_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(debugName: 'NSDraggingSource');
  NSDraggingSource.draggingSession_sourceOperationMaskForDraggingContext_
      .implement(
        builder,
        draggingSession_sourceOperationMaskForDraggingContext_,
      );
  NSDraggingSource.draggingSession_willBeginAtPoint_.implementAsBlocking(
    builder,
    draggingSession_willBeginAtPoint_,
  );
  NSDraggingSource.draggingSession_movedToPoint_.implementAsBlocking(
    builder,
    draggingSession_movedToPoint_,
  );
  NSDraggingSource.draggingSession_endedAtPoint_operation_
      .implementAsBlocking(builder, draggingSession_endedAtPoint_operation_);
  NSDraggingSource.ignoreModifierKeysForDraggingSession_.implement(
    builder,
    ignoreModifierKeysForDraggingSession_,
  );
  builder.addProtocol($protocol);
  return NSDraggingSource.castFrom(
    builder.build(keepIsolateAlive: $keepIsolateAlive),
  );
}