Share via


NSTextView.Notifications.ObserveDidChangeSelection Method

Definition

Overloads

ObserveDidChangeSelection(EventHandler<NSTextViewDidChangeSelectionEventArgs>)

Strongly typed notification for the DidChangeSelectionNotification constant.

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

Parameters

handler
EventHandler<NSTextViewDidChangeSelectionEventArgs>

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 DidChangeSelectionNotification notifications.

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

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

Applies to

ObserveDidChangeSelection(NSObject, EventHandler<NSTextViewDidChangeSelectionEventArgs>)

Strongly typed notification for the DidChangeSelectionNotification constant.

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

Parameters

objectToObserve
NSObject

The specific object to observe.

handler
EventHandler<NSTextViewDidChangeSelectionEventArgs>

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 DidChangeSelectionNotification notifications.

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

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

Applies to