Added NSText notifications to delegate

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8380 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 2000-12-20 12:50:15 +00:00
parent 0db3418ed7
commit 05aa0c954d

View file

@ -59,10 +59,10 @@ NSRange MakeRangeFromAbs (unsigned a1, unsigned a2)
} }
#define SET_DELEGATE_NOTIFICATION(notif_name) \ #define SET_DELEGATE_NOTIFICATION(notif_name) \
if ([_delegate respondsToSelector: @selector(textView##notif_name: )]) \ if ([_delegate respondsToSelector: @selector(text##notif_name: )]) \
[nc addObserver: _delegate \ [nc addObserver: _delegate \
selector: @selector(textView##notif_name: ) \ selector: @selector(text##notif_name: ) \
name: NSTextView##notif_name##Notification \ name: NSText##notif_name##Notification \
object: _notifObject] object: _notifObject]
/* MINOR FIXME: The following two should really be kept in the /* MINOR FIXME: The following two should really be kept in the
@ -407,8 +407,16 @@ static NSNotificationCenter *nc;
if ((_delegate != nil) && (oldNotifObject != _notifObject)) if ((_delegate != nil) && (oldNotifObject != _notifObject))
{ {
[nc removeObserver: _delegate name: nil object: oldNotifObject]; [nc removeObserver: _delegate name: nil object: oldNotifObject];
SET_DELEGATE_NOTIFICATION (DidChangeSelection);
SET_DELEGATE_NOTIFICATION (WillChangeNotifyingTextView); /* SET_DELEGATE_NOTIFICATION defined at the beginning of file */
/* NSText notifications */
SET_DELEGATE_NOTIFICATION (DidBeginEditing);
SET_DELEGATE_NOTIFICATION (DidChange);
SET_DELEGATE_NOTIFICATION (DidEndEditing);
/* NSTextView notifications */
SET_DELEGATE_NOTIFICATION (ViewDidChangeSelection);
SET_DELEGATE_NOTIFICATION (ViewWillChangeNotifyingTextView);
} }
} }
@ -1383,6 +1391,7 @@ container, returning the modified location. */
- (void) setDelegate: (id)anObject - (void) setDelegate: (id)anObject
{ {
/* Code to allow sharing the delegate */
if (_tvf.multiple_textviews && (isSynchronizingDelegate == NO)) if (_tvf.multiple_textviews && (isSynchronizingDelegate == NO))
{ {
/* Invoke setDelegate: on all the textviews which share this /* Invoke setDelegate: on all the textviews which share this
@ -1407,11 +1416,24 @@ container, returning the modified location. */
} }
/* Now the real code to set the delegate */ /* Now the real code to set the delegate */
if (_delegate != nil)
{
[nc removeObserver: _delegate name: nil object: _notifObject];
}
[super setDelegate: anObject]; [super setDelegate: anObject];
/* SET_DELEGATE_NOTIFICATION defined at the beginning of file */ /* SET_DELEGATE_NOTIFICATION defined at the beginning of file */
SET_DELEGATE_NOTIFICATION (DidChangeSelection);
SET_DELEGATE_NOTIFICATION (WillChangeNotifyingTextView); /* NSText notifications */
SET_DELEGATE_NOTIFICATION (DidBeginEditing);
SET_DELEGATE_NOTIFICATION (DidChange);
SET_DELEGATE_NOTIFICATION (DidEndEditing);
/* NSTextView notifications */
SET_DELEGATE_NOTIFICATION (ViewDidChangeSelection);
SET_DELEGATE_NOTIFICATION (ViewWillChangeNotifyingTextView);
} }
@end @end