-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHighlightingTextFieldCell.m
More file actions
30 lines (26 loc) · 1.18 KB
/
HighlightingTextFieldCell.m
File metadata and controls
30 lines (26 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// HighlightingTextFieldCell.m
// SSDP Browser
//
// Created by Thomas Tempelmann on 28.02.24.
// Copyright © 2024 Thomas Tempelmann. All rights reserved.
//
#import "HighlightingTextFieldCell.h"
#import "SSDPDocument.h"
@implementation HighlightingTextFieldCell
//
// This is a bit of a trick: The Cells in the NSOutlineView bind to the "objectRef" property of TreeNode,
// and their NSTextFieldCell instances have different `tag` values set (first col is 0, the other is 1).
// This function below gets called when the NSCell is set up, and it gets the bound value passed here,
// i.e. the value from TreeNode.objectRef, which is the TreeNode itself. We then pass it to our
// SSDPDocument class which can decide which string to assign to this NSCell's objectValue.
//
- (void)setObjectValue:(id)objectValue {
if ([objectValue isKindOfClass:TreeNode.class]) {
// we want to replace the string with an attributed string if there's a search filter set
id docHandler = self.controlView.window.delegate; // we blindly assume this is of the SSDPDocument type
objectValue = [(SSDPDocument*)docHandler highlightedObjectValue:self node:objectValue];
}
super.objectValue = objectValue;
}
@end