implement static method

NSMenuDelegate implement({
  1. void menuNeedsUpdate_(
    1. NSMenu
    )?,
  2. DartNSInteger numberOfItemsInMenu_(
    1. NSMenu
    )?,
  3. bool menu_updateItem_atIndex_shouldCancel_(
    1. NSMenu,
    2. NSMenuItem,
    3. DartNSInteger,
    4. bool,
    )?,
  4. bool menuHasKeyEquivalent_forEvent_target_action_(
    1. NSMenu,
    2. NSEvent,
    3. Pointer<Pointer<ObjCObject>>,
    4. Pointer<Pointer<ObjCSelector>>,
    )?,
  5. void menuWillOpen_(
    1. NSMenu
    )?,
  6. void menuDidClose_(
    1. NSMenu
    )?,
  7. void menu_willHighlightItem_(
    1. NSMenu,
    2. NSMenuItem?
    )?,
  8. NSRect confinementRectForMenu_onScreen_(
    1. NSMenu,
    2. NSScreen?
    )?,
  9. bool $keepIsolateAlive = true,
})

Builds an object that implements the NSMenuDelegate protocol. To implement multiple protocols, use addToBuilder or objc.ObjCProtocolBuilder directly.

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

Implementation

static NSMenuDelegate implement({
  void Function(NSMenu)? menuNeedsUpdate_,
  DartNSInteger Function(NSMenu)? numberOfItemsInMenu_,
  bool Function(NSMenu, NSMenuItem, DartNSInteger, bool)?
  menu_updateItem_atIndex_shouldCancel_,
  bool Function(
    NSMenu,
    NSEvent,
    ffi.Pointer<ffi.Pointer<objc.ObjCObject>>,
    ffi.Pointer<ffi.Pointer<objc.ObjCSelector>>,
  )?
  menuHasKeyEquivalent_forEvent_target_action_,
  void Function(NSMenu)? menuWillOpen_,
  void Function(NSMenu)? menuDidClose_,
  void Function(NSMenu, NSMenuItem?)? menu_willHighlightItem_,
  NSRect Function(NSMenu, NSScreen?)? confinementRectForMenu_onScreen_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(debugName: 'NSMenuDelegate');
  NSMenuDelegate.menuNeedsUpdate_.implement(builder, menuNeedsUpdate_);
  NSMenuDelegate.numberOfItemsInMenu_.implement(
    builder,
    numberOfItemsInMenu_,
  );
  NSMenuDelegate.menu_updateItem_atIndex_shouldCancel_.implement(
    builder,
    menu_updateItem_atIndex_shouldCancel_,
  );
  NSMenuDelegate.menuHasKeyEquivalent_forEvent_target_action_.implement(
    builder,
    menuHasKeyEquivalent_forEvent_target_action_,
  );
  NSMenuDelegate.menuWillOpen_.implement(builder, menuWillOpen_);
  NSMenuDelegate.menuDidClose_.implement(builder, menuDidClose_);
  NSMenuDelegate.menu_willHighlightItem_.implement(
    builder,
    menu_willHighlightItem_,
  );
  NSMenuDelegate.confinementRectForMenu_onScreen_.implement(
    builder,
    confinementRectForMenu_onScreen_,
  );
  builder.addProtocol($protocol);
  return NSMenuDelegate.castFrom(
    builder.build(keepIsolateAlive: $keepIsolateAlive),
  );
}