0

Requirements
I want to implement the option to hide password input in a custom NSTextView. String data should be set to the underlying model - though it should not be displayed in the view. Instead bullets or nothing at all should be displayed. There should also be the option to show the password.

Experiments
Therefore, I am searching for a delegate method that notifies me when text has been entered. The closest method I found by now is the following.

textViewDidChangeSelection: // NSTextViewDelegate

I tried the following methods to alter the text of the textStorage - without success.

shouldChangeTextInRange:replacementString: // NSTextView
replaceCharactersInRange:withString: // NSTextStorage
setAttributedString: // NSTextStorage
setString: // NSText

Questions

  1. What delegate method would be suitable?
  2. How can I substitute the displayed text without changing the model data?

Disclaimer
I am developing an application with a dark user interface. So, I need to change back- and foreground colors. There are annoying problems like coloring the text cursor that cannot be done with an NSTextField. That's why I want to implement the secure text field with an NSTextView.

JJD
  • 50,076
  • 60
  • 203
  • 339
  • 1
    Why not use NSSecureTextField? Is there a reason it must be an NSTextView? – Peter Hosey Jan 02 '12 at 20:24
  • I need to customize the ui which I cannot with a NSTextField. – JJD Jan 02 '12 at 21:12
  • What do you mean by “customize the UI”? Depending on what you're doing, it may in fact be possible with NSSecureTextField. – Peter Hosey Jan 02 '12 at 21:18
  • 1
    I found an [excellent example on how to customize an `NSSecureTextField`](http://stackoverflow.com/questions/2258300/nstextfield-white-text-on-black-background-but-black-cursor/8713572#8713572) posted by @jon-steinmetz. – JJD Jan 03 '12 at 14:29
  • @JonSteinmetz should be the correct reference. – JJD Jan 05 '12 at 00:29

0 Answers0