adde re-selection of groups when exiting search.

This commit is contained in:
Michael Starke
2022-11-14 09:42:53 +01:00
parent 289a27c7e7
commit 59f4fd0ae0
2 changed files with 13 additions and 2 deletions

View File

@@ -50,7 +50,6 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
[NSNotificationCenter.defaultCenter postNotificationName:MPDocumentDidEnterSearchNotification object:self];
[self updateSearch:self];
/* clear selection */
self.selectedGroups = nil;
self.selectedEntries = nil;
}

View File

@@ -46,6 +46,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
@interface MPOutlineViewController () {
BOOL _bindingEstablished;
NSIndexSet *_storedSelectionIndexSet;
MPOutlineContextMenuDelegate *_menuDelegate;
}
@@ -100,7 +101,6 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
name:MPDidActivateViewNotification
object:self.outlineView];
NSView *clipView = self.outlineView.enclosingScrollView.contentView;
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(_outlineDidScroll:)
@@ -226,6 +226,8 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
- (void)registerNotificationsForDocument:(MPDocument *)document {
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didAddGroup:) name:MPDocumentDidAddGroupNotification object:document];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didRevertDocument:) name:MPDocumentDidRevertNotification object:document];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didEnterSearch:) name:MPDocumentDidEnterSearchNotification object:document];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didExitSearch:) name:MPDocumentDidExitSearchNotification object:document];
}
- (void)clearSelection {
@@ -273,6 +275,16 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
[self clearSelection];
}
- (void)_didEnterSearch:(NSNotification *)notification {
// store seelection
_storedSelectionIndexSet = self.outlineView.selectedRowIndexes;
[self clearSelection];
}
- (void)_didExitSearch:(NSNotification *)notification {
[self.outlineView selectRowIndexes:_storedSelectionIndexSet byExtendingSelection:NO];
}
- (id)itemUnderMouse {
NSPoint mouseLocation = [self.outlineView.window mouseLocationOutsideOfEventStream];
NSPoint localPoint = [self.outlineView convertPoint:mouseLocation fromView:self.outlineView.window.contentView];