diff options
author | rowanbeentje <rowan@beent.je> | 2011-08-28 23:37:12 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2011-08-28 23:37:12 +0000 |
commit | 667965deb096dfddee663701627eb0364f350a9a (patch) | |
tree | 0f67fa31adfedfa6fc1f161fbd7bf100575c07cd | |
parent | 2e85893ca0c0ce416402a2783067996a38ff8b66 (diff) | |
download | sequelpro-667965deb096dfddee663701627eb0364f350a9a.tar.gz sequelpro-667965deb096dfddee663701627eb0364f350a9a.tar.bz2 sequelpro-667965deb096dfddee663701627eb0364f350a9a.zip |
- Disable and re-enable table view double click actions when opening and closing sheets for a window; this addresses beeping when editing cells using the field editor sheet.
-rw-r--r-- | Source/SPTableView.m | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Source/SPTableView.m b/Source/SPTableView.m index 9139bb79..e135e16b 100644 --- a/Source/SPTableView.m +++ b/Source/SPTableView.m @@ -37,6 +37,8 @@ @interface SPTableView (PrivateAPI) - (void)_doubleClickAction; +- (void)_disableDoubleClickAction:(NSNotification *)notification; +- (void)_enableDoubleClickAction:(NSNotification *)notification; @end @@ -60,6 +62,23 @@ [super awakeFromNib]; } +/** + * Track window changes, in order to add listeners for when sheets are shown + * or hidden; this allows the double-click action to be disabled while sheets + * are open, preventing beeps when using the field editor on double-click. + */ +- (void) viewWillMoveToWindow:(NSWindow *)aWindow { + NSNotificationCenter *notifier = [NSNotificationCenter defaultCenter]; + + [notifier removeObserver:self name:NSWindowWillBeginSheetNotification object:nil]; + [notifier removeObserver:self name:NSWindowDidEndSheetNotification object:nil]; + + if (aWindow) { + [notifier addObserver:self selector:@selector(_disableDoubleClickAction:) name:NSWindowWillBeginSheetNotification object:aWindow]; + [notifier addObserver:self selector:@selector(_enableDoubleClickAction:) name:NSWindowDidEndSheetNotification object:aWindow]; + } +} + #pragma mark - /** @@ -238,4 +257,23 @@ } } +/** + * When a sheet is opened on this window, disable the double-click action. + * This prevents beeping when a double-click results in a rejected cell edit but + * opens a sheet such as the field editor sheet. + */ +- (void)_disableDoubleClickAction:(NSNotification *)notification +{ + [super setDoubleAction:NULL]; +} + +/** + * Restore the double-click action after the sheet is closed. + */ +- (void)_enableDoubleClickAction:(NSNotification *)notification +{ + [super setDoubleAction:@selector(_doubleClickAction)]; +} + + @end |