Vanishing NSTextField Text

I have a custom view in a .xib file, which I use as the contentViewController for an MAAttachedWindow. The view has several NSTextFields in it.

When I open the MAAttachedWindow first time, everything is fine. Text shows up in all relevant text fields. Then, if I close the window (which sets it to nil) and then call it again (which reinitializes, using the same custom view as the contentViewController), the last firstResponder text field is now blank.

The strange thing is that if I click the "empty" text field, it shows the correct text. This can be edited, and behaves appropriately as long as this text field has focus. As soon as something else becomes firstResponder, the text vanishes again.

Updates:

  • Changing the color did not change the aforementioned behavior.
  • The text color does not change at any time during this process.
  • Placeholder text also is subject to the aforementioned behavior.
  • No errors are occurring at any time during this process.
  • This does not happen to NSSecureTextFields.

Answers


I first encountered this problem about 5 years ago with accessory view of a NSSavePanel. The solution that I've found was to move the first responder to the panel itself, before it's closed. Here's my exact method:

- (void)windowDidEndSheet:(NSNotification *)notification

    NSSavePanel *savePanel = [(XSDocument *)[self document] savePanel];
    if (!savePanel)
        return;
    // this fixes a bug where on next opening one of accessory view's text field will be blank and behave strangely
    [savePanel makeFirstResponder:savePanel];
}

Need Your Help

How do I create an Open With Dialog in iOS?

ios objective-c

I have a app that creates jpg images. Now I want to open a dialog which shows all the possible apps which can open a jpg image. When I tap on one of the apps in the dialog the tapped app should be ...

Overriding or aliasing name of column in legacy database using Rails/ActiveRecord

ruby-on-rails database activerecord

I'm writing a Rails application against a legacy database. One of the tables in this legacy database has a column named object_id. Unfortunately object_id is also an attribute of every object in Ru...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.