mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 08:00:58 +00:00
Make key equivalent modifier string user adjustable by getting them from the defaults.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32579 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
32a98382fc
commit
dfb02833a0
3 changed files with 90 additions and 23 deletions
|
@ -1,3 +1,11 @@
|
|||
2011-03-14 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSMenuItemCell.m: Make key equivalent modifier string
|
||||
user adjustable by getting them from the defaults.
|
||||
* Documentation/GuiUser/DefaultsSummary.gsdoc: Document the new
|
||||
equivalent modifier strings and remove the now obsolete
|
||||
documentation for GSFileBrowserHideDotFiles.
|
||||
|
||||
2011-03-14 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSSavePanel.m (-_initWithoutGModel): Use an image view
|
||||
|
|
|
@ -93,14 +93,6 @@
|
|||
it is). Default is <code>Control-q</code>.
|
||||
</p>
|
||||
</desc>
|
||||
<term>GSFileBrowserHideDotFiles</term>
|
||||
<desc>
|
||||
<p>
|
||||
A boolean, by default NO. If you set it to YES, files that
|
||||
begin with a dot ('.') are not shown in the NSSavePanel or
|
||||
NSOpenPanel.
|
||||
</p>
|
||||
</desc>
|
||||
<term>GSUseGhostResize</term>
|
||||
<desc>
|
||||
<p>
|
||||
|
@ -223,6 +215,38 @@
|
|||
for background server applications.
|
||||
</p>
|
||||
</desc>
|
||||
<term>GSControlKeyString</term>
|
||||
<desc>
|
||||
<p>
|
||||
A string used in the menu to signify that the control key needs to
|
||||
be pressed together with the key equivalent of the menu item.
|
||||
Default "^".
|
||||
</p>
|
||||
</desc>
|
||||
<term>GSAlternateKeyString</term>
|
||||
<desc>
|
||||
<p>
|
||||
A string used in the menu to signify that the alternate key needs to
|
||||
be pressed together with the key equivalent of the menu item.
|
||||
Default "+".
|
||||
</p>
|
||||
</desc>
|
||||
<term>GSShiftKeyString</term>
|
||||
<desc>
|
||||
<p>
|
||||
A string used in the menu to signify that the shift key needs to
|
||||
be pressed together with the key equivalent of the menu item.
|
||||
Default "/".
|
||||
</p>
|
||||
</desc>
|
||||
<term>GSCommandKeyString</term>
|
||||
<desc>
|
||||
<p>
|
||||
A string used in the menu to signify that the command key needs to
|
||||
be pressed together with the key equivalent of the menu item.
|
||||
Default "#".
|
||||
</p>
|
||||
</desc>
|
||||
<term>NSInterfaceStyleDefault</term>
|
||||
<desc>
|
||||
<p>
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSCoder.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSException.h>
|
||||
//#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
//#import <Foundation/NSNotification.h>
|
||||
//#import <Foundation/NSProcessInfo.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
|
||||
|
@ -49,6 +49,10 @@
|
|||
#import "GNUstepGUI/GSTheme.h"
|
||||
#import "GSGuiPrivate.h"
|
||||
|
||||
static NSString *controlKeyString = @"^";
|
||||
static NSString *alternateKeyString = @"+";
|
||||
static NSString *shiftKeyString = @"/";
|
||||
static NSString *commandKeyString = @"#";
|
||||
|
||||
@implementation NSMenuItemCell
|
||||
|
||||
|
@ -56,7 +60,30 @@
|
|||
{
|
||||
if (self == [NSMenuItemCell class])
|
||||
{
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString *keyString;
|
||||
|
||||
[self setVersion: 2];
|
||||
keyString = [userDefaults objectForKey: @"GSControlKeyString"];
|
||||
if (nil != keyString)
|
||||
{
|
||||
controlKeyString = keyString;
|
||||
}
|
||||
keyString = [userDefaults objectForKey: @"GSAlternateKeyString"];
|
||||
if (nil != keyString)
|
||||
{
|
||||
alternateKeyString = keyString;
|
||||
}
|
||||
keyString = [userDefaults objectForKey: @"GSShiftKeyString"];
|
||||
if (nil != keyString)
|
||||
{
|
||||
shiftKeyString = keyString;
|
||||
}
|
||||
keyString = [userDefaults objectForKey: @"GSCommandKeyString"];
|
||||
if (nil != keyString)
|
||||
{
|
||||
commandKeyString = keyString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +94,10 @@
|
|||
|
||||
- (id) init
|
||||
{
|
||||
[super init];
|
||||
self = [super init];
|
||||
if (nil == self)
|
||||
return nil;
|
||||
|
||||
[self setButtonType: NSMomentaryLightButton];
|
||||
[self setAlignment: NSLeftTextAlignment];
|
||||
[self setFont: [NSFont menuFontOfSize: 0]];
|
||||
|
@ -197,7 +227,6 @@
|
|||
NSString *key = [_menuItem keyEquivalent];
|
||||
unsigned int m = [_menuItem keyEquivalentModifierMask];
|
||||
NSString *ucKey = [key uppercaseString];
|
||||
BOOL shift;
|
||||
unichar uchar;
|
||||
|
||||
if ((key == nil) || [key isEqualToString: @""])
|
||||
|
@ -216,17 +245,21 @@
|
|||
else if ([key isEqualToString: @"\\e"])
|
||||
key = @"ESC";
|
||||
else if ([key isEqualToString: @"\\d"])
|
||||
key=@"DEL";
|
||||
key = @"DEL";
|
||||
|
||||
if (m != 0)
|
||||
{
|
||||
BOOL shift;
|
||||
// shift mask and not an upper case string?
|
||||
shift = (m & NSShiftKeyMask) & ![key isEqualToString: ucKey];
|
||||
key = [NSString stringWithFormat:@"%@%@%@%@%@",
|
||||
(m & NSControlKeyMask) ? controlKeyString : @"",
|
||||
(m & NSAlternateKeyMask) ? alternateKeyString : @"",
|
||||
shift ? shiftKeyString : @"",
|
||||
(m & NSCommandKeyMask) ? commandKeyString : @"",
|
||||
key];
|
||||
}
|
||||
|
||||
// shift mask and not an upper case string?
|
||||
shift = (m & NSShiftKeyMask) & ![key isEqualToString: ucKey];
|
||||
|
||||
key = [NSString stringWithFormat:@"%@%@%@%@%@",
|
||||
(m & NSControlKeyMask) ? @"^" : @"",
|
||||
(m & NSAlternateKeyMask) ? @"+" : @"",
|
||||
shift ? @"/" : @"",
|
||||
(m & NSCommandKeyMask) ? @"#" : @"",
|
||||
key];
|
||||
return key;
|
||||
}
|
||||
|
||||
|
@ -925,6 +958,8 @@
|
|||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
self = [super initWithCoder: aDecoder];
|
||||
if (nil == self)
|
||||
return nil;
|
||||
|
||||
if ([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue