Skip to content

Commit

Permalink
Merge pull request #207 from MarkJerde/close_bezel_when_focus_lost
Browse files Browse the repository at this point in the history
Make bezel close when it loses focus
  • Loading branch information
TermiT authored Aug 2, 2020
2 parents 6e575e8 + cd26c65 commit c7654e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion AppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

@class SGHotKey;

@interface AppController : NSObject <NSMenuDelegate, NSApplicationDelegate, NSAlertDelegate, FlycutStoreDelegate, FlycutOperatorDelegate> {
@interface AppController : NSObject <NSMenuDelegate, NSApplicationDelegate, NSAlertDelegate, FlycutStoreDelegate, FlycutOperatorDelegate, BezelWindowDelegate> {
BezelWindow *bezel;
SGHotKey *mainHotKey;
IBOutlet SRRecorderControl *mainRecorder;
Expand Down Expand Up @@ -97,6 +97,7 @@
-(void) processBezelKeyDown:(NSEvent *)theEvent;
-(void) processBezelMouseEvents:(NSEvent *)theEvent;
-(void) metaKeysReleased;
-(void) windowDidResignKey:(NSNotification *)notification;

// Menu related
-(void) updateMenu;
Expand Down
8 changes: 7 additions & 1 deletion AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,12 @@ - (void)metaKeysReleased
}
}

- (void)windowDidResignKey:(NSNotification *)notification {
if ( isBezelPinned ) {
[self hideApp];
}
}

-(void)fakeKey:(NSNumber*) keyCode withCommandFlag:(BOOL) setFlag
/*" +fakeKey synthesizes keyboard events. "*/
{
Expand Down Expand Up @@ -1059,8 +1065,8 @@ - (void) hideBezel

-(void)hideApp
{
[self hideBezel];
isBezelPinned = NO;
[self hideBezel];
[NSApp hide:self];
}

Expand Down
13 changes: 10 additions & 3 deletions UI/BezelWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
#import "RoundRecBezierPath.h"
#import "RoundRecTextField.h"

@protocol BezelWindowDelegate <NSWindowDelegate>

-(void)processBezelKeyDown:(NSEvent *)theEvent;
-(void)processBezelMouseEvents:(NSEvent *)theEvent;
-(void)metaKeysReleased;

@end

@interface BezelWindow : NSPanel {
// "n of n" text in bezel
Expand All @@ -33,7 +40,7 @@
RoundRecTextField *textField;
RoundRecTextField *charField;
NSImageView *iconView;
id delegate;
id<BezelWindowDelegate> delegate;
Boolean color;
}

Expand All @@ -57,7 +64,7 @@
- (void)setDate:(NSString *)newDate;
- (void)setSourceIcon:(NSImage *)newSourceIcon;

- (id)delegate;
- (void)setDelegate:(id)newDelegate;
- (id<BezelWindowDelegate>)delegate;
- (void)setDelegate:(id<BezelWindowDelegate>)newDelegate;

@end
5 changes: 3 additions & 2 deletions UI/BezelWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,13 @@ - (void)flagsChanged:(NSEvent *)theEvent {
}
}

- (id)delegate {
- (id<BezelWindowDelegate>)delegate {
return delegate;
}

- (void)setDelegate:(id)newDelegate {
- (void)setDelegate:(id<BezelWindowDelegate>)newDelegate {
delegate = newDelegate;
super.delegate = newDelegate;
}

@end

0 comments on commit c7654e0

Please sign in to comment.