I have a programmatically created AppKit/Cocoa NSTextField, within a tab in a popup. I'm creating the control with:
NSTextField *textField = [[NSTextField alloc] init];
[textField setBezeled:YES];
[textField setDrawsBackground:YES];
[textField setEditable:YES];
[textField setSelectable:NO];
[textField setTranslatesAutoresizingMaskIntoConstraints:NO];
return textField;
And then inserting it into the parent NSView (in a tab control in a dialog box) with various layout constraints, and it appears in the correct place. However, the text field is not editable or selectable. If I change the instantiation to
[textField setSelectable:YES];
the control shows up in the tree view in the Debug View Hierarchy tool in XCode, with the same constraints that I'd expect, but the view isn't visible on screen, or in the visual display of the Debug View Hierarchy tool.
And even with [textField setSelectable:NO]
, I cannot edit the text that I've set in the control.
XCode Version 9.4.1 (9F2000) / macOS High Sierra 10.13.5
NSTextField
'sselectable
: "If NO, the text is neither editable nor selectable". What is the size of the text field on screen? – Willekeselectable:NO
, but I figured I'd try, since at least then it's visible). Is the problem that I need to add a minimum size constraint? – Dan Lyke