(drawKeyEquivalentWithFrame:inView:): check if item is disabled/enabled and set

color attribute for attributed key equivalent string.
This commit is contained in:
Sergii Stoian 2019-04-10 00:40:20 +03:00
parent 9295b2311b
commit 1b0e90686a
2 changed files with 20 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2019-04-10 Sergii Stoian <stoyan255@ukr.net>
* Source/NSMenuItemCell.m (drawKeyEquivalentWithFrame:inView:):
check if item is disabled/enabled and set color attribute for attributed
key equivalent string.
2019-04-09 Sergii Stoian <stoyan255@gmail.com>
* Source/NSMenuItemCell.m (_keyEquivalentString): if modifier key string

View file

@ -787,10 +787,21 @@ static NSString *commandKeyString = @"#";
if (_keyEquivalentFont != nil)
{
NSDictionary *attrs;
NSArray *attrObjects, *attrKeys;
NSAttributedString *aString;
attrs = [NSDictionary dictionaryWithObject: _keyEquivalentFont
forKey: NSFontAttributeName];
NSColor *aColor;
if (_cell.is_disabled)
aColor = [NSColor disabledControlTextColor];
else
aColor = [NSColor controlTextColor];
attrObjects = [NSArray arrayWithObjects: _keyEquivalentFont,
aColor, nil];
attrKeys = [NSArray arrayWithObjects: NSFontAttributeName,
NSForegroundColorAttributeName, nil];
attrs = [NSDictionary dictionaryWithObjects: attrObjects
forKeys: attrKeys];
aString = [[NSAttributedString alloc]
initWithString: [self _keyEquivalentString]
attributes: attrs];