• 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: NSTextField overwrites itself
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextField overwrites itself


  • Subject: Re: NSTextField overwrites itself
  • From: Nathan Lee <email@hidden>
  • Date: Sat, 18 May 2002 00:21:20 -0400

Try using an NSTextView (the one with the vertical scroll bars) instead
of your NSTextField, and then using the method [textView insertText:
NSString].
This ought to append the NSString to the end of the current contents of
the NSTextView. If you've got your heart set on using an NSTextField,
there may be a way, but all I can think of is retrieving the current
NSString value, appending your new NSString and then putting the new one
in. I'm just a beginner with Cocoa, so I may be wrong, but this is a
problem I recently resolved, so I thought I might lend a hand.


On Friday, May 17, 2002, at 06:23 PM, email@hidden
wrote:

> Date: Fri, 17 May 2002 13:29:32 -0700
> Subject: NSTextField overwrites itself
> From: Mark Slater <email@hidden>
> To: email@hidden
>
> I'm trying to implement a window that monitors a thread. Sometimes it
> all looks good, but more often than not, the NSTextFields on the window
> will overwrite themselves... you can make out the current value and one
> or more previous values. The thread processes data in batches, and at
> the end of each batch, it sends an update notification to the window
> controller class. There is generally 1-5 seconds between updates...
> sometimes longer but rarely shorter... and they don't ever seem to
> overlap. Is there some kind of trick in changing the text field string
> that ensures only the current value is drawn and the old value is erased
> first?
>
> The Window containing the fields is set to Buffered in IB. Also, I'm not
> able to turn on "Draws Background" for the NSTextFields.
>
> Thanks in advance!
>
> Mark
>
> // Source code snippet.
>
> - (void) updateStatus: (NSNotification *) notification
> {
> NSDictionary *statusDict = [ notification userInfo ];
>
> printf("Update status\n");
>
> // Disable window flushing until all fields have been updated.
> [ [ self getStatusWindow ] disableFlushWindow ];
>
> [ self
> updateTextField: [ self getStatusText ]
> text: [ statusDict objectForKey: threadStatusKey ] ];
>
> [ self
> updateTextField: [ self getUnfinishedImagesText ]
> text: [ [ statusDict objectForKey: numUnfinishedImagesKey ]
> stringValue ] ];
>
> [ self
> updateTextField: [ self getFinishedImagesText ]
> text: [ [ statusDict objectForKey: numFinishedImagesKey ]
> stringValue ] ];
>
> // Enable window flushing now that all fields have been updated.
> [ [ self getStatusWindow ] enableFlushWindow ];
> printf(" Update status done\n");
> }
>
> /**
> * Make sure the text of a text field matches the desired text.
> */
> - (void) updateTextField: (NSTextField *) textField text: (NSString *)
> text
> {
> NSString *currentText = [ textField stringValue ];
>
> // Only change the field if the text is different.
> if( ![ currentText isEqual: text ] )
> {
> [ textField setStringValue: text ];
> }
> }
>
>
--


. ''~``
. ( o o )
+-oooO--(_)--Oooo-------------------------------------------+
| Nathan C. Lee |
| |
| email@hidden |
| (513) 706-5950 |
| oooO |
| ( ) Oooo "Life is short. Make fun of it." |
+--\ (-----( )--------------------------------------------+
. \_) ) /
. (_/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Dock Magnification Effect
  • Next by Date: Re: Dock Magnification Effect
  • Previous by thread: Re: NSTextField overwrites itself
  • Next by thread: Dos anybody now how to use "setUsesThreadedAnimation" NSProgressIndicator control.
  • Index(es):
    • Date
    • Thread