Re: controlTextDidChange, backspace possible?
Re: controlTextDidChange, backspace possible?
- Subject: Re: controlTextDidChange, backspace possible?
- From: j o a r <email@hidden>
- Date: Tue, 14 Sep 2004 16:35:18 +0200
Store a copy of the string every time you get the notification. If the
string changes to a length > 32, simply restore the previous string.
j o a r
On 2004-09-14, at 16.00, Peter Karlsson wrote:
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.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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