• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: controlTextDidChange, backspace possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: controlTextDidChange, backspace possible?


  • Subject: Re: controlTextDidChange, backspace possible?
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Tue, 14 Sep 2004 17:07:34 +0200

At 14:00 Uhr +0000 14.09.2004, Peter Karlsson wrote:
If I have the cursor in the middle of the string the last character of the string will dissapear for every new character I type.

Yes, that's exactly what your code does, as it doesn't take into account the selection.


My idea is to make a backspace so the latest character will not be typed if the string is already 32 characters in length. Is this possible to do, or is there better solutions?

Have you looked at NSFormatter? It looks like writing an NSFormatter of your own will let you do just what you want.


The point is, I do not want anything to happen at all if I type and the string is already 32 characters in length. So I must find a way to delete the latest character typed regardless of the position in the string.

If NSFormatter (which would be reusable and looks like the "recommended way") doesn't let you do what you want, another option might be to replace the field editor in your window with one where you've overridden the keyDown: method. Then you could check that there. Or switch to an NSTextView subclass instead of an NSTextField.


But NSFormatter sounds like it will be a lot less painful in the long run. And I'm sure lots of people here would be pleased if you put up such a formatter for download somewhere. Length-limiting text entry fields is a common enough problem that I don't get why there isn't a solution built in already.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: controlTextDidChange, backspace possible?
      • From: Ondra Cada <email@hidden>
References: 
 >controlTextDidChange, backspace possible? (From: "Peter Karlsson" <email@hidden>)

  • Prev by Date: Re: Debugging "attempt to insert nil value" on customer's machine
  • Next by Date: Country codes vs. Language codes
  • Previous by thread: Re: controlTextDidChange, backspace possible?
  • Next by thread: Re: controlTextDidChange, backspace possible?
  • Index(es):
    • Date
    • Thread