mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Fixes to NSHelpManager
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4876 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0dd419d272
commit
8d932ec1c0
3 changed files with 82 additions and 20 deletions
28
ChangeLog
28
ChangeLog
|
@ -1,3 +1,31 @@
|
|||
1999-09-10 Pedro Ivo Andrade Tavares <ptavares@iname.com>
|
||||
|
||||
* NSResponder.m ([NSResponder -helpRequested:]):
|
||||
Now the application exits context help mode regardless of whether
|
||||
help was shown or not. Without it, the app would do nothing while
|
||||
the user didn't click on a control with help, and would appear
|
||||
broken.
|
||||
* NSHelpManager.m
|
||||
([NSBundle -contextHelpForKey:]): implemented. See below.
|
||||
([NSApplication -showHelp:]): implemented. See below.
|
||||
([NSHelpManager -contextHelpForObject:]): minor change.
|
||||
|
||||
Context Help for an application is stored in a file called
|
||||
Help.plist. Inside it are several dictionaries, each with the
|
||||
name of what originally was an RTF or RTFD file. Inside each of
|
||||
these dicts, a key called NSHelpRTFContents contains an
|
||||
NSArchived NSAttributedString from the original file. NSBundle
|
||||
receives the original RTF file name, and retrieves the
|
||||
NSAttributedString from this file. Thanks to Richard
|
||||
Frith-MacDonald for unearthing the format of Help.plist.
|
||||
|
||||
I've implemented an extension, in that NSBundle also looks inside
|
||||
an directory called Help for a file of this name.
|
||||
|
||||
NSApplication -showHelp: asks the workspace to open in the default
|
||||
editor a file of name "appname.rtf", or what is in the key
|
||||
GSHelpContentsFile in the Info-gnustep.plist file.
|
||||
|
||||
Sat Sep 11 11:20:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Headers/AppKit/NSCell.h: Removed ([-_drawImage:inFrame:])
|
||||
|
|
|
@ -42,10 +42,31 @@
|
|||
|
||||
- (NSAttributedString*) contextHelpForKey: (NSString*) key
|
||||
{
|
||||
// FIXME
|
||||
/* There are some issues here. I still have to understand how
|
||||
does Help.plist work. */
|
||||
NSLog(@"contextHelpForKey not implemented yet.");
|
||||
id helpFile = nil;
|
||||
NSDictionary *contextHelp =
|
||||
[[NSDictionary dictionaryWithContentsOfFile:
|
||||
[self pathForResource: @"Help" ofType: @"plist"]] retain];
|
||||
|
||||
if(contextHelp)
|
||||
{
|
||||
helpFile = [contextHelp objectForKey: key];
|
||||
}
|
||||
|
||||
if(helpFile)
|
||||
{
|
||||
return [NSUnarchiver unarchiveObjectWithData:
|
||||
[helpFile objectForKey: @"NSHelpRTFContents"]];
|
||||
}
|
||||
else
|
||||
{
|
||||
helpFile = [self
|
||||
pathForResource: key
|
||||
ofType: @"rtf"
|
||||
inDirectory: @"Help"];
|
||||
return [[[NSAttributedString alloc] initWithPath: (NSString *)helpFile
|
||||
documentAttributes: nil] autorelease];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -55,10 +76,19 @@
|
|||
|
||||
- (void) showHelp: (id)sender
|
||||
{
|
||||
// FIXME
|
||||
/* This is obviously very restrictive. The ideal would be to check
|
||||
the Resources first, but this can be done later. */
|
||||
[[NSWorkspace sharedWorkspace] openFile: @"Help.rtf"];
|
||||
NSBundle *mb = [NSBundle mainBundle];
|
||||
NSDictionary *info = [mb infoDictionary];
|
||||
NSString *help;
|
||||
|
||||
help = [info objectForKey: @"GSHelpContentsFile"];
|
||||
|
||||
if(!help)
|
||||
{
|
||||
help = [info objectForKey: @"NSExecutable"];
|
||||
// If there's no specification, we look for a file named "appname.rtf"
|
||||
[[NSWorkspace sharedWorkspace]
|
||||
openFile: [mb pathForResource: help ofType: @"rtf"]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) activateContextHelpMode: (id)sender
|
||||
|
@ -134,8 +164,9 @@ static BOOL _gnu_contextHelpActive = NO;
|
|||
loaded.
|
||||
If it's nil, there's no help for this object, and that's what we return.
|
||||
If it's an NSString, it's the path for the help, and we ask NSBundle
|
||||
for it (This part has to be written, so:) */
|
||||
// FIXME
|
||||
for it. */
|
||||
// FIXME: Check this implementation when NSResponders finally store what
|
||||
// their context help is.
|
||||
|
||||
id hc = NSMapGet(contextHelpTopics, object);
|
||||
if(hc)
|
||||
|
@ -143,7 +174,13 @@ static BOOL _gnu_contextHelpActive = NO;
|
|||
if(![hc isKindOfClass: [NSAttributedString class]])
|
||||
{
|
||||
hc = [[NSBundle mainBundle] contextHelpForKey: hc];
|
||||
NSMapInsert(contextHelpTopics, object, hc);
|
||||
/* We store the retrieved value, or remove the key from
|
||||
the table if nil returns (note that it's OK if the key
|
||||
does not exist already. */
|
||||
if (hc)
|
||||
NSMapInsert(contextHelpTopics, object, hc);
|
||||
else
|
||||
NSMapRemove(contextHelpTopics, object);
|
||||
}
|
||||
}
|
||||
return hc;
|
||||
|
|
|
@ -123,15 +123,12 @@
|
|||
|
||||
- (void) helpRequested: (NSEvent *)theEvent
|
||||
{
|
||||
if([[NSHelpManager sharedHelpManager]
|
||||
showContextHelpForObject: self
|
||||
locationHint: [theEvent locationInWindow]])
|
||||
{
|
||||
[NSHelpManager setContextHelpModeActive: NO];
|
||||
}
|
||||
else
|
||||
if (next_responder)
|
||||
return [next_responder helpRequested: theEvent];
|
||||
if(![[NSHelpManager sharedHelpManager]
|
||||
showContextHelpForObject: self
|
||||
locationHint: [theEvent locationInWindow]])
|
||||
if (next_responder)
|
||||
return [next_responder helpRequested: theEvent];
|
||||
[NSHelpManager setContextHelpModeActive: NO];
|
||||
}
|
||||
|
||||
- (void) keyDown: (NSEvent *)theEvent
|
||||
|
|
Loading…
Reference in a new issue