mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 01:10:39 +00:00
Corrected delegate setup
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3731 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9fd1de051c
commit
663c70afac
5 changed files with 92 additions and 33 deletions
|
@ -1585,35 +1585,51 @@ NSLog(@"keycode:%x",keyCode);
|
|||
//
|
||||
// Managing the Delegate
|
||||
//
|
||||
- delegate { return delegate; }
|
||||
- (id) delegate
|
||||
{
|
||||
return delegate;
|
||||
}
|
||||
|
||||
-(void) setDelegate:anObject
|
||||
{ delegate = anObject;
|
||||
-(void) setDelegate: (id)anObject
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
if (delegate)
|
||||
[nc removeObserver: delegate name: nil object: self];
|
||||
delegate = anObject;
|
||||
|
||||
#define SET_DELEGATE_NOTIFICATION(notif_name) \
|
||||
if ([delegate respondsToSelector: @selector(text##notif_name:)]) \
|
||||
[nc addObserver: delegate \
|
||||
selector: @selector(text##notif_name:) \
|
||||
name: NSText##notif_name##Notification \
|
||||
object: self]
|
||||
|
||||
SET_DELEGATE_NOTIFICATION(DidBeginEditing);
|
||||
SET_DELEGATE_NOTIFICATION(DidChange);
|
||||
SET_DELEGATE_NOTIFICATION(DidEndEditing);
|
||||
}
|
||||
|
||||
//
|
||||
// Implemented by the Delegate
|
||||
//
|
||||
|
||||
-(void) textDidBeginEditing:(NSNotification *)aNotification
|
||||
{ if ([delegate respondsToSelector:@selector(textDidBeginEditing:)])
|
||||
[delegate textDidBeginEditing:aNotification? aNotification:[NSNotification notificationWithName:NSTextDidBeginEditingNotification object:self]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidBeginEditingNotification object:self];
|
||||
-(void) textDidBeginEditing: (NSNotification*)aNotification
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSTextDidBeginEditingNotification object: self];
|
||||
}
|
||||
|
||||
- (void)textDidChange:(NSNotification *)aNotification
|
||||
{ if ([delegate respondsToSelector:@selector(textDidChange:)])
|
||||
[delegate textDidChange:aNotification? aNotification:[NSNotification notificationWithName:NSTextDidChangeNotification object:self]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidChangeNotification object:self];
|
||||
- (void) textDidChange: (NSNotification*)aNotification
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSTextDidChangeNotification object: self];
|
||||
}
|
||||
|
||||
-(void)textDidEndEditing:(NSNotification *)aNotification
|
||||
{ if ([delegate respondsToSelector:@selector(textDidEndEditing:)])
|
||||
[delegate textDidEndEditing:aNotification? aNotification:[NSNotification notificationWithName:NSTextDidEndEditingNotification object:self]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidEndEditingNotification object:self];
|
||||
-(void) textDidEndEditing: (NSNotification*)aNotification
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSTextDidEndEditingNotification object: self];
|
||||
}
|
||||
|
||||
-(BOOL) textShouldBeginEditing:(NSText *)textObject
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue