Share via


NSMenu.Notifications.ObserveWillSendAction Method

Definition

Overloads

ObserveWillSendAction(EventHandler<NSMenuItemEventArgs>)

Strongly typed notification for the WillSendActionNotification constant.

public static Foundation.NSObject ObserveWillSendAction(EventHandler<AppKit.NSMenuItemEventArgs> handler);
static member ObserveWillSendAction : EventHandler<AppKit.NSMenuItemEventArgs> -> Foundation.NSObject

Parameters

handler
EventHandler<NSMenuItemEventArgs>

The handler that responds to the notification when it occurs.

Returns

Token object that can be used to stop receiving notifications by either disposing it or passing it to RemoveObservers(IEnumerable<NSObject>).

Remarks

This method can be used to subscribe to WillSendActionNotification notifications.

// Listen to all notifications posted for any object
var token = NSMenu.Notifications.ObserveWillSendAction ((notification) => {
  Console.WriteLine ("Observed WillSendActionNotification!");
};

// Stop listening for notifications
token.Dispose ();

Applies to

ObserveWillSendAction(NSObject, EventHandler<NSMenuItemEventArgs>)

Strongly typed notification for the WillSendActionNotification constant.

public static Foundation.NSObject ObserveWillSendAction(Foundation.NSObject objectToObserve, EventHandler<AppKit.NSMenuItemEventArgs> handler);
static member ObserveWillSendAction : Foundation.NSObject * EventHandler<AppKit.NSMenuItemEventArgs> -> Foundation.NSObject

Parameters

objectToObserve
NSObject

The specific object to observe.

handler
EventHandler<NSMenuItemEventArgs>

The handler that responds to the notification when it occurs.

Returns

Token object that can be used to stop receiving notifications by either disposing it or passing it to RemoveObservers(IEnumerable<NSObject>).

Remarks

This method can be used to subscribe to WillSendActionNotification notifications.

// Listen to all notifications posted for a single object
var token = NSMenu.Notifications.ObserveWillSendAction (objectToObserve, (notification) => {
  Console.WriteLine ($"Observed WillSendActionNotification for {nameof (objectToObserve)}!");
};

// Stop listening for notifications
token.Dispose ();

Applies to