mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 05:10:47 +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
af0c1f62e9
commit
4026532377
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>
|
Sat Sep 11 11:20:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Headers/AppKit/NSCell.h: Removed ([-_drawImage:inFrame:])
|
* Headers/AppKit/NSCell.h: Removed ([-_drawImage:inFrame:])
|
||||||
|
|
|
@ -42,10 +42,31 @@
|
||||||
|
|
||||||
- (NSAttributedString*) contextHelpForKey: (NSString*) key
|
- (NSAttributedString*) contextHelpForKey: (NSString*) key
|
||||||
{
|
{
|
||||||
// FIXME
|
id helpFile = nil;
|
||||||
/* There are some issues here. I still have to understand how
|
NSDictionary *contextHelp =
|
||||||
does Help.plist work. */
|
[[NSDictionary dictionaryWithContentsOfFile:
|
||||||
NSLog(@"contextHelpForKey not implemented yet.");
|
[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;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,10 +76,19 @@
|
||||||
|
|
||||||
- (void) showHelp: (id)sender
|
- (void) showHelp: (id)sender
|
||||||
{
|
{
|
||||||
// FIXME
|
NSBundle *mb = [NSBundle mainBundle];
|
||||||
/* This is obviously very restrictive. The ideal would be to check
|
NSDictionary *info = [mb infoDictionary];
|
||||||
the Resources first, but this can be done later. */
|
NSString *help;
|
||||||
[[NSWorkspace sharedWorkspace] openFile: @"Help.rtf"];
|
|
||||||
|
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
|
- (void) activateContextHelpMode: (id)sender
|
||||||
|
@ -134,8 +164,9 @@ static BOOL _gnu_contextHelpActive = NO;
|
||||||
loaded.
|
loaded.
|
||||||
If it's nil, there's no help for this object, and that's what we return.
|
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
|
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:) */
|
for it. */
|
||||||
// FIXME
|
// FIXME: Check this implementation when NSResponders finally store what
|
||||||
|
// their context help is.
|
||||||
|
|
||||||
id hc = NSMapGet(contextHelpTopics, object);
|
id hc = NSMapGet(contextHelpTopics, object);
|
||||||
if(hc)
|
if(hc)
|
||||||
|
@ -143,7 +174,13 @@ static BOOL _gnu_contextHelpActive = NO;
|
||||||
if(![hc isKindOfClass: [NSAttributedString class]])
|
if(![hc isKindOfClass: [NSAttributedString class]])
|
||||||
{
|
{
|
||||||
hc = [[NSBundle mainBundle] contextHelpForKey: hc];
|
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;
|
return hc;
|
||||||
|
|
|
@ -123,15 +123,12 @@
|
||||||
|
|
||||||
- (void) helpRequested: (NSEvent *)theEvent
|
- (void) helpRequested: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
if([[NSHelpManager sharedHelpManager]
|
if(![[NSHelpManager sharedHelpManager]
|
||||||
showContextHelpForObject: self
|
showContextHelpForObject: self
|
||||||
locationHint: [theEvent locationInWindow]])
|
locationHint: [theEvent locationInWindow]])
|
||||||
{
|
if (next_responder)
|
||||||
[NSHelpManager setContextHelpModeActive: NO];
|
return [next_responder helpRequested: theEvent];
|
||||||
}
|
[NSHelpManager setContextHelpModeActive: NO];
|
||||||
else
|
|
||||||
if (next_responder)
|
|
||||||
return [next_responder helpRequested: theEvent];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) keyDown: (NSEvent *)theEvent
|
- (void) keyDown: (NSEvent *)theEvent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue