implement static method
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),
);
}