• 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: "Peter Karlsson" <email@hidden>
  • Date: Tue, 14 Sep 2004 15:52:27 +0000

This is what my code looks like at the moment:

-(void)controlTextDidChange:(id)sender
{
	if ([[myTexfieldOutlet stringValue] length] == 32)
		{
		latestString = [myTexfieldOutlet stringValue];
		[latestString retain];
		}

	if ([[myTexfieldOutlet stringValue] length] > 32)
		{
		[myTexfieldOutlet setStringValue:latestString];
		}
}

It seems to work except if I type a character in the middle of a 32 character string, the cursor moves one character to the right for every time I type a character. I want the cursor to stand still!

It's strange that a common thing like this is so hard in OS X. Why don't have a field in IB where I just type 32 for length, period!

Peter




From: j o a r <email@hidden>
To: Harilaos Skiadas <email@hidden>
CC: email@hidden, email@hidden
Subject: Re: controlTextDidChange, backspace possible?
Date: Tue, 14 Sep 2004 17:30:02 +0200

To override you need to subclass, and that's something I try to avoid if possible.

Also, yes, you probably need a custom field editor - as "insertText:" is a NSTextView method, and Peter asked for a way to limit the string length in a NSTextField.

j o a r

On 2004-09-14, at 17.19, Harilaos Skiadas wrote:

just wondering, could he also override the insertText:
method to check the length of the string and not send
any text if the string is longer than 32 characters?
If so, where would be the right place to do that?
Would he need a custom field editor?
<< smime.p7s >>

_________________________________________________________________
STOP MORE 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: Ondra Cada <email@hidden>
    • Re: controlTextDidChange, backspace possible?
      • From: Harilaos Skiadas <email@hidden>
    • Re: controlTextDidChange, backspace possible?
      • From: Frederick Cheung <email@hidden>
  • Prev by Date: Re: how to composite NSBezierPath and text on an image
  • Next by Date: Re: Creating Help for my App.
  • Previous by thread: Re: controlTextDidChange, backspace possible?
  • Next by thread: Re: controlTextDidChange, backspace possible?
  • Index(es):
    • Date
    • Thread