开发者

How to hide focus ring for NSTextFieldCell?

开发者 https://www.devze.com 2023-04-10 11:00 出处:网络
I\'m trying to get this blue border (which is around a NSTextFieldCell when you can edit the value) out of the way. Is there a way manage this somehow? At the same time the user should still be able t

I'm trying to get this blue border (which is around a NSTextFieldCell when you can edit the value) out of the way. Is there a way manage this somehow? At the same time the user should still be able to change the text just by double-clicking, thou开发者_高级运维gh.

For the table itself I got rid of it by setting this Focus ring option to None. But I can't find it for any Text Field unfortunately...


Don't forget to check superclasses when looking in the docs for something. In this case, since NSTextFieldCell inherits from NSCell, you want to use -[NSCell setFocusRingType:].

The easiest way to get the cell before it becomes focused is probably the NSTableViewDelegate method tableView:shouldEditTableColumn:row:

- (BOOL)tableView:(NSTableView *)tableView 
shouldEditTableColumn:(NSTableColumn *)tableColumn 
                  row:(NSInteger)row 
{        
    NSTextFieldCell * cell = [tableColumn dataCellForRow:row];
    [cell setFocusRingType:NSFocusRingTypeNone];
    return YES;
}
0

精彩评论

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

关注公众号