Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Real-updating for NSTextView

Real-updating for NSTextView
Thread Tools
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Apr 10, 2001, 10:28 PM
 
Alrighty, I want to print out a bunch of text into an NSTextView object. Seems pretty easy: (I'm using java)

Code:
NSTextView output; public void test(NSButton sender) { for(int i=0; i++; i<10000) { output.insertText("" + i + " "); } }
Seem simple enough? Well, the only problem is that the NSTextView object isn't being updated in real time - it waits till the loop is done thinking and then updates the screen. Is there anyway to make the NSTextView object act more like STDOUT in terminal (aka u type something, and lines and lines of "stuff" flies by).

Thanks,
F-bacher
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Apr 11, 2001, 01:16 PM
 
Perhaps it would update if the code was in a thread? I don't really know anything about threads, just hazarding a guess.

You could also try sending the NSTextView an update message (I think that's right, or updateIfNeeded or something... Check the AppKit ref ), but that might cause flicker.
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Apr 11, 2001, 05:04 PM
 
I got it. Just called this after ever output.insertText("blah") call:

[code]
output.drawRect(output.bounds());
[code]

Thanks,
F-bacher
     
ali
Forum Regular
Join Date: Sep 2000
Status: Offline
Reply With Quote
Apr 11, 2001, 05:24 PM
 
drawRect() is not meant to be called directly; it's meant to be implemented by subclassers of NSView, and the drawing machinery is supposed to call it for you.

To force a redraw, call displayIfNeeded() or display(). Given you just changed the view, displayIfNeeded() should do the right thing.

Ali
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:01 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2