-- (BOOL)outlineView:(NSOutlineView *)outlineView
- isGroupItem:(NJInputPathElement *)item {
- return [item isKindOfClass:NJDevice.class];
-}
-
-- (BOOL)outlineView:(NSOutlineView *)outlineView_
- shouldSelectItem:(NJInputPathElement *)item {
- return ![self outlineView:outlineView_ isGroupItem:item];
-}
-
-- (void)outlineViewItemDidExpand:(NSNotification *)notification {
- NJInputPathElement *item = notification.userInfo[@"NSObject"];
- NSString *uid = item.uid;
- if (![_expanded containsObject:uid])
- [_expanded addObject:uid];
- while (_expanded.count > EXPANDED_MEMORY_MAX_SIZE)
- [_expanded removeObjectAtIndex:0];
- [NSUserDefaults.standardUserDefaults setObject:_expanded
- forKey:@"expanded rows"];
-}
-
-- (void)outlineViewItemDidCollapse:(NSNotification *)notification {
- NJInputPathElement *item = notification.userInfo[@"NSObject"];
- [_expanded removeObject:item.uid];
- [NSUserDefaults.standardUserDefaults setObject:_expanded
- forKey:@"expanded rows"];
-}
-
-- (void)setTranslatingEvents:(BOOL)translatingEvents {
- if (translatingEvents != _translatingEvents) {
- _translatingEvents = translatingEvents;
- NSInteger state = translatingEvents ? NSOnState : NSOffState;
- translatingEventsButton.state = state;
- NSString *name = translatingEvents
- ? NJEventTranslationActivated
- : NJEventTranslationDeactivated;
- [NSNotificationCenter.defaultCenter postNotificationName:name
- object:self];
-
- if (!translatingEvents && !NSApplication.sharedApplication.isActive)
- [self stopHid];
- else
- [self startHid];
- }
-}
-
-- (void)reexpandAll {
- for (NSString *uid in [_expanded copy])
- [self expandRecursiveByUID:uid];
- if (outlineView.selectedRow == -1) {
- NSString *selectedUid = [NSUserDefaults.standardUserDefaults objectForKey:@"selected input"];
- id item = [self elementForUID:selectedUid];
- NSInteger row = [outlineView rowForItem:item];
- if (row >= 0)
- [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
- }