2009-12-19 26 views
5

Khi tôi nhấn nút "+" trên một hàng trong NSRuleEditor, một hàng mới sẽ được tạo. Làm thế nào tôi có thể ảnh hưởng đến các tiêu chí được sử dụng cho hàng đó.NSRuleEditor: Tiêu chí cho hàng mới

Dường như NSRuleEditor mặc định chọn tuần tự đầu tiên từ danh sách các giá trị có thể. Tôi muốn có hàng mới phù hợp với hàng nơi "+" được nhấp vào.

Trả lời

2

tôi đã có thể giả mạo nó bằng cách subclassing một phương pháp riêng:

- (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]; 
    } 
} 
Các vấn đề liên quan