controlTextDidChange, backspace possible?
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