2020-04-21 05:07:14 +00:00
|
|
|
/* All rights reserved */
|
2006-10-23 05:16:42 +00:00
|
|
|
|
|
|
|
#include <AppKit/AppKit.h>
|
2019-11-03 01:57:39 +00:00
|
|
|
|
2008-12-02 07:54:31 +00:00
|
|
|
#include <GNUstepGUI/GSNibLoading.h>
|
2006-10-23 05:16:42 +00:00
|
|
|
|
2019-11-03 01:57:39 +00:00
|
|
|
#include "GormHelpInspector.h"
|
|
|
|
|
2006-10-23 05:16:42 +00:00
|
|
|
@implementation GormHelpInspector
|
|
|
|
- (id) init
|
|
|
|
{
|
2023-06-14 07:40:51 +00:00
|
|
|
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
|
|
|
|
|
2006-10-23 05:16:42 +00:00
|
|
|
if ([super init] == nil)
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2023-06-14 07:40:51 +00:00
|
|
|
if ([bundle loadNibNamed: @"GormHelpInspector" owner: self topLevelObjects: nil] == NO)
|
2006-10-23 05:16:42 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Could not gorm GormHelpInspector");
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) ok: (id)sender
|
|
|
|
{
|
2023-06-17 16:14:48 +00:00
|
|
|
id<IBDocuments> document = [(id<IB>)[NSApp delegate] activeDocument];
|
2006-10-23 05:16:42 +00:00
|
|
|
NSArray *cons = [document connectorsForDestination: object
|
|
|
|
ofClass: [NSIBHelpConnector class]];
|
|
|
|
NSIBHelpConnector *con = nil;
|
|
|
|
|
|
|
|
if([cons count] > 0)
|
|
|
|
{
|
|
|
|
NSEnumerator *en = [cons objectEnumerator];
|
|
|
|
NSString *val = [sender stringValue];
|
|
|
|
|
|
|
|
if([val isEqualToString: @""] == NO)
|
|
|
|
{
|
|
|
|
while((con = [en nextObject]) != nil)
|
|
|
|
{
|
|
|
|
[con setMarker: [sender stringValue]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while((con = [en nextObject]) != nil)
|
|
|
|
{
|
|
|
|
[document removeConnector: con];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
con = [[NSIBHelpConnector alloc] init];
|
|
|
|
|
|
|
|
[con setFile: @"NSToolTipHelpKey"];
|
|
|
|
[con setMarker: [sender stringValue]];
|
|
|
|
[con setDestination: object];
|
|
|
|
|
|
|
|
[document addConnector: con];
|
|
|
|
}
|
|
|
|
[super ok: sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) revert: (id)sender
|
|
|
|
{
|
2023-06-17 16:14:48 +00:00
|
|
|
id<IBDocuments> document = [(id<IB>)[NSApp delegate] activeDocument];
|
2006-10-23 05:16:42 +00:00
|
|
|
NSArray *cons = [document connectorsForDestination: object
|
|
|
|
ofClass: [NSIBHelpConnector class]];
|
|
|
|
|
|
|
|
if([cons count] > 0)
|
|
|
|
{
|
|
|
|
NSIBHelpConnector *con = [cons objectAtIndex: 0];
|
|
|
|
NSString *val = [con marker];
|
|
|
|
[toolTip setStringValue: val];
|
|
|
|
}
|
2006-10-23 05:24:39 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[toolTip setStringValue: @""];
|
|
|
|
}
|
|
|
|
|
2006-10-23 05:16:42 +00:00
|
|
|
[super revert: sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) controlTextDidChange:(NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
[self ok: [aNotification object]];
|
|
|
|
}
|
|
|
|
@end
|