NSControl's setCellClass is deprecated in OS X 10.10 what's the alternative for overriding NSTextField's cell class?
Asked Answered
H

2

18

I'm attempting to follow the post linked below to override the NSCell of a NSTextField but it looks like the setCellClass method is now deprecated in OSX 10.10.

How to make NSTextField use custom subclass of NSTextFieldCell?

How should one override the NSTextField's cell substituting it for a subclass?

The reason for doing this is to vertically centre the text of a NSTextField cell which Apple have made very difficult.

Herodias answered 2/3, 2015 at 12:15 Comment(1)
Did you find any solution?Pegeen
K
1
public override class var cellClass: AnyClass? { get { YourCustomCell.self } set {} }

on the NSControl subclass seems to work.

Kaslik answered 4/9, 2021 at 20:30 Comment(0)
H
0

The short answer is: don't. As per the release notes, NSCell itself is being 'gradually deprecated'.

To vertically align some text, you can use layout constraints. Depending on the situation, you might need to put the NSTextField inside a larger NSView.

Hornswoggle answered 14/2, 2017 at 18:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.