Use NSNumberFormatter as correctly suggested. You can set its -positiveSuffix: 
string to "Days" and that's it. You're done.

--Graham





On 28/04/2012, at 2:41 PM, Rick C. wrote:

> Thanks for the reply but unfortunately I'm still stuck.  Yes I did try the 
> delegate methods before posting here.  I did not try the formatter methods 
> but can't figure out a way to make it work either.  None of these methods 
> seem to get called if the text field is still in focus and the value is still 
> highlighted.  Now if I would tab to another text field it's no problem 
> because mouseDown will get called again.  But with only clicking Enter and 
> immediately trying to edit again by clicking with the mouse (while the value 
> is still highlighted) nothing seems to get called.  What am I missing here?  
> Thanks,
> 
> rc
> 
> 
> 
> On Apr 28, 2012, at 12:34 AM, Charlie Dickman wrote:
> 
>> You should have a look at the documentation for NSFormatter. You can define 
>> a formatter for your text field that gets called when a number of different 
>> things happen to/in the text field.
>> 
>> You might also want to have a look at the delegate methods available for an 
>> NSTextField which get called when other things happen to/in the field.
>> 
>> At first you might think that building a formatter for a field that already 
>> does what you want is redundant but you may find that the advantage of being 
>> able to get control at virtually all stages of editing is worth it. I 
>> certainly do.
>> 
>> On Apr 27, 2012, at 12:12 PM, Rick C. wrote:
>> 
>>> Hi,
>>> 
>>> I might be getting sleepy and overlooking the obvious, but I have a panel 
>>> with a few text fields and I'm trying to figure out what gets called after 
>>> entering a value into a text field and while it's still highlighted 
>>> clicking it again?  In my case when entering a value into one of my text 
>>> fields (let's say "30") I append a string to that value (let's say "Days"). 
>>>  I do this in the action method.  In my subclass in mouseDown I make it 
>>> where if the value is "30 Days" when clicking the text field I will remove 
>>> the "Days" so the user can easily edit only the "30" and I append the 
>>> "Days" once again in the action method.  My problem is after clicking Enter 
>>> for that text field if the user would try to edit it again without that 
>>> text field ever losing focus the "Days" is not removed because mouseDown 
>>> doesn't get called.  And I haven't been able to figure out what does get 
>>> called in this situation?  Thanks,


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to