implementAsBlocking static method

NSTextDelegate implementAsBlocking({
  1. bool textShouldBeginEditing_(
    1. NSText
    )?,
  2. bool textShouldEndEditing_(
    1. NSText
    )?,
  3. void textDidBeginEditing_(
    1. NSNotification
    )?,
  4. void textDidEndEditing_(
    1. NSNotification
    )?,
  5. void textDidChange_(
    1. NSNotification
    )?,
  6. bool $keepIsolateAlive = true,
})

Builds an object that implements the NSTextDelegate 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 NSTextDelegate implementAsBlocking({
  bool Function(NSText)? textShouldBeginEditing_,
  bool Function(NSText)? textShouldEndEditing_,
  void Function(objc.NSNotification)? textDidBeginEditing_,
  void Function(objc.NSNotification)? textDidEndEditing_,
  void Function(objc.NSNotification)? textDidChange_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(debugName: 'NSTextDelegate');
  NSTextDelegate.textShouldBeginEditing_.implement(
    builder,
    textShouldBeginEditing_,
  );
  NSTextDelegate.textShouldEndEditing_.implement(
    builder,
    textShouldEndEditing_,
  );
  NSTextDelegate.textDidBeginEditing_.implementAsBlocking(
    builder,
    textDidBeginEditing_,
  );
  NSTextDelegate.textDidEndEditing_.implementAsBlocking(
    builder,
    textDidEndEditing_,
  );
  NSTextDelegate.textDidChange_.implementAsBlocking(builder, textDidChange_);
  builder.addProtocol($protocol);
  return NSTextDelegate.castFrom(
    builder.build(keepIsolateAlive: $keepIsolateAlive),
  );
}