Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTextField placeholder text doesn't show unless editing

I set the placeholder text of my NSTextField in Interface Builder, but the placeholder text doesn't show until I click inside the text field to edit it.

like image 974
indragie Avatar asked Apr 01 '11 22:04

indragie


People also ask

How does the NSTextField class work?

The NSTextField class uses the NSTextFieldCell class to implement its user interface. Text fields display text either as a static label or as an editable input field.

What is nstextfielddelegate in Salesforce?

var delegate: NSTextFieldDelegate? The text field’s delegate. Requests permission to begin editing a text object. Posts a notification to the default notification center that the text is about to go into edit mode. Posts a notification when the text changes, and forwards the message to the text field’s cell if it responds.

How to set the values of the text field in nscontrol?

The parent class, NSControl, provides the methods for setting the values of the text field, such as stringValue and doubleValue. There are corresponding methods to retrieve values. In macOS 12 and later, if you explicitly call the layoutManager property on your text field, the framework will revert to a compatibility mode that uses NSLayoutManager.

What does @enum selecttext (any) do?

func selectText(Any?) Ends editing in the text field and, if it’s selectable, selects the entire text content. A Boolean value that indicates whether the text field is editable and accepts first responder status.


2 Answers

Have you tried setting the placeholder through code? for example something like this:

    [[textField cell] setPlaceholderString:@"hello"];
like image 137
Johann Dirdal Avatar answered Sep 20 '22 04:09

Johann Dirdal


Have you bound the NSTextField data in Interface Builder? If so, you have to set the "Multiple Values Placeholder", "No Selection Placeholder" and "Null Placeholder" in the bindings tab in your Utilities inspector. While youre at it, you could set the "No Applicable Placeholder" as well.

like image 28
GJ Nilsen Avatar answered Sep 21 '22 04:09

GJ Nilsen