Cocoa NSRuleEditor:新行的条件
当我在NSRuleEditor中单击某行上的“+”按钮时,将创建一个新行。我如何对该行使用的标准施加影响Cocoa NSRuleEditor:新行的条件,cocoa,Cocoa,当我在NSRuleEditor中单击某行上的“+”按钮时,将创建一个新行。我如何对该行使用的标准施加影响 NSRuleEditor似乎默认从可能值列表中依次选择第一个标准。我更希望新行与单击“+”的行匹配。我可以通过对私有方法进行子类化来伪造它: - (void)_addOptionFromSlice:(id)slice ofRowType:(unsigned int)type { int rowIndex = [(NSRuleEditorViewSlice*)slice rowInde
NSRuleEditor似乎默认从可能值列表中依次选择第一个标准。我更希望新行与单击“+”的行匹配。我可以通过对私有方法进行子类化来伪造它:
- (void)_addOptionFromSlice:(id)slice ofRowType:(unsigned int)type
{
int rowIndex = [(NSRuleEditorViewSlice*)slice rowIndex];
NSArray *criteriaForRow = [self criteriaForRow:rowIndex];
NSArray *displayValuesForRow = [self displayValuesForRow:rowIndex];
self.template = [NSArray arrayWithObjects:criteriaForRow, displayValuesForRow, nil];
[super _addOptionFromSlice:slice ofRowType:type];
}
- (void)insertRowAtIndex:(NSInteger)rowIndex withType:(NSRuleEditorRowType)rowType asSubrowOfRow:(NSInteger)parentRow animate:(BOOL)shouldAnimate
{
[super insertRowAtIndex:rowIndex withType:rowType asSubrowOfRow:parentRow animate:shouldAnimate];
NSArray *template = self.template;
if (template != nil) {
[self setCriteria:[template objectAtIndex:0] andDisplayValues:[template objectAtIndex:1] forRowAtIndex:rowIndex];
}
}