• 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
controlTextDidChange, backspace possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

controlTextDidChange, backspace possible?


  • Subject: controlTextDidChange, backspace possible?
  • From: "Peter Karlsson" <email@hidden>
  • Date: Tue, 14 Sep 2004 14:00:38 +0000

Dear list!

I have the following code to limit the length of the string I type in my textfield:

-(void)controlTextDidChange:(id)sender
{
// 32 character limit on my textfield
if ([[myTextfieldOutlet stringValue] length] > 32)
{
[myTextfieldOutlet setStringValue: [NSString stringWithString:[[myTextfieldOutlet stringValue] substringToIndex: 32]]];
}
}


I can only type 32 characters, wonderful but...

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.

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?

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.

Best regards Peter

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail


_______________________________________________
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: "M. Uli Kusterer" <email@hidden>
    • Re: controlTextDidChange, backspace possible?
      • From: j o a r <email@hidden>
  • Prev by Date: Re: Embedding other WebViews?
  • Next by Date: Re: controlTextDidChange, backspace possible?
  • Previous by thread: Re: NSUndoManager in non-document based app using bindings
  • Next by thread: Re: controlTextDidChange, backspace possible?
  • Index(es):
    • Date
    • Thread