开发者

Prevent selection change in NSOutlineView when NSActionCell clicked

开发者 https://www.devze.com 2022-12-21 17:15 出处:网络
I have a custom NSActionCe开发者_如何转开发ll used to render some parts of some of the rows in my NSOutlineView. I can receive and respond to clicks on the NSActionCell, but the selection also changes

I have a custom NSActionCe开发者_如何转开发ll used to render some parts of some of the rows in my NSOutlineView. I can receive and respond to clicks on the NSActionCell, but the selection also changes when that cell is clicked. I'd like to prevent the selection from changing if one of my custom NSActionCells are clicked.

Is there an easy way to do this?


To answer my own question:

If the cell you want to be able to click (and subsequently not select a row) is in it's own column, then the following Apple example is very useful:

DragNDropOutlineView

That example relies on implementing the following NSOutlineViewDelegate method (implemented in AppController.m at line 304):

- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item

If you have a cell within another cell, you can still use that approach, but you'll need to do a bit more work to determine whether the mouse was clicked within your sub-cell. A good example demonstrating that logic is the following Apple example:

PhotoSearch

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号