cocoa - How to force redrawing a group row in a NSOutlineView after it’s been expanded/collapsed -
i tried calling setneedsdysplay:
, setneedsdisplayinrect:
drawbackgroundinrect:
, drawseparatorinrect:
not called group row else
this piece of code have:
- (void)outlineview:(nsoutlineview *)outlineview didaddrowview:(nstablerowview *)rowview forrow:(nsinteger)row { id previtem = [outlineview itematrow:row - 1]; if ([self outlineview:outlineview isgroupitem:previtem]) { id view = [self outlineview:outlineview rowviewforitem:previtem]; if (view) { [view setneedsdisplay:yes]; } } }
edit
this came with:
- (void)outlineview:(nsoutlineview *)outlineview didremoverowview:(nstablerowview *)rowview forrow:(nsinteger)row { // todo: find a better way repaint node after it's been collapsed (nsview *view in outlineview.subviews) { nsinteger testrow = [outlineview rowforview:view]; if (testrow == row - 1) { id item = [outlineview itematrow:testrow]; if ([(id)outlineview outlineview:outlineview isgroupitem:item]) { [view setneedsdisplay:yes]; } } } } - (void)outlineview:(nsoutlineview *)outlineview didaddrowview:(nstablerowview *)rowview forrow:(nsinteger)row { // todo: find a better way repaint node after it's been expanded (nsview *view in outlineview.subviews) { nsinteger testrow = [outlineview rowforview:view]; if (testrow == row - 1) { id item = [outlineview itematrow:testrow]; if ([(id)outlineview outlineview:outlineview isgroupitem:item]) { [view setneedsdisplay:yes]; } } } }
...but it's slow in cases
ok, did trick:
- (void)outlineviewitemdidcollapse:(nsnotification *)notification { nsinteger row = [_outlineview rowforitem:notification.userinfo[@"nsobject"]]; nsview *rowview = [_outlineview rowviewatrow:row makeifnecessary:no]; [rowview setneedsdisplay:yes]; } - (void)outlineviewitemdidexpand:(nsnotification *)notification { nsinteger row = [_outlineview rowforitem:notification.userinfo[@"nsobject"]]; nsview *rowview = [_outlineview rowviewatrow:row makeifnecessary:no]; [rowview setneedsdisplay:yes]; }
Comments
Post a Comment