diff options
| author | Vadim Shpakovski | 2015-02-12 19:57:02 +0300 | 
|---|---|---|
| committer | Vadim Shpakovski | 2015-02-12 19:57:02 +0300 | 
| commit | 3ea350cec127d7118ef64f0e84a9ad84fa249a11 (patch) | |
| tree | cda359764e14b342e6d2d9571dcbe0dd38dda361 | |
| parent | ef399290e4a9b8e575688807be301e975c6a543e (diff) | |
| parent | aeaad2986f322ce7fcdde2ef7fb8049a62f5a0d6 (diff) | |
| download | MASShortcut-3ea350cec127d7118ef64f0e84a9ad84fa249a11.tar.bz2 | |
Merge pull request #65 from oreshinya/add_option_showing_delete_hotkey_button
Added options to show button that delete hot key.
| -rw-r--r-- | Framework/MASShortcutView.m | 14 | 
1 files changed, 11 insertions, 3 deletions
| diff --git a/Framework/MASShortcutView.m b/Framework/MASShortcutView.m index d521880..cb6f3d9 100644 --- a/Framework/MASShortcutView.m +++ b/Framework/MASShortcutView.m @@ -13,6 +13,7 @@ NSString *const MASShortcutBinding = @"shortcutValue";  @property (nonatomic, getter = isHinting) BOOL hinting;  @property (nonatomic, copy) NSString *shortcutPlaceholder; +@property (nonatomic, assign) BOOL showsDeleteButton;  @end @@ -57,6 +58,7 @@ NSString *const MASShortcutBinding = @"shortcutValue";      _shortcutCell.font = [[NSFontManager sharedFontManager] convertFont:_shortcutCell.font toSize:BUTTON_FONT_SIZE];      _shortcutValidator = [MASShortcutValidator sharedValidator];      _enabled = YES; +    _showsDeleteButton = YES;      [self resetShortcutCellStyle];  } @@ -188,9 +190,15 @@ NSString *const MASShortcutBinding = @"shortcutValue";  - (void)drawRect:(CGRect)dirtyRect  {      if (self.shortcutValue) { -        [self drawInRect:self.bounds withTitle:NSStringFromMASKeyCode(self.recording ? kMASShortcutGlyphEscape : kMASShortcutGlyphClear) -               alignment:NSRightTextAlignment state:NSOffState]; -         +        NSString *buttonTitle; +        if (self.recording) { +            buttonTitle = NSStringFromMASKeyCode(kMASShortcutGlyphEscape); +        } else if (self.showsDeleteButton) { +            buttonTitle = NSStringFromMASKeyCode(kMASShortcutGlyphClear); +        } +        if (buttonTitle != nil) { +            [self drawInRect:self.bounds withTitle:buttonTitle alignment:NSRightTextAlignment state:NSOffState]; +        }          CGRect shortcutRect;          [self getShortcutRect:&shortcutRect hintRect:NULL];          NSString *title = (self.recording | 
