Making a control draw while I'm in a (tightish) loop
Making a control draw while I'm in a (tightish) loop
- Subject: Making a control draw while I'm in a (tightish) loop
- From: Andy <email@hidden>
- Date: Mon, 21 Jan 2002 22:43:41 -0500
Hi,
I have a search function in my application, which displays multiple
pages of data. I need t search through each page, looking for something
the user wants.
Obviously, if the target turns out to be many pages on from where the
user currently is, by app becomes busy and the rainbow cursor appears.
I'd like to show the user some kind of progress indicator. The full on
progress bar seems like overkill for a search function... I've not seen
many implemented this way. The "Chasing Arrows" carbon control seems
missing from cocoa for now?
My app also shows page numbers, so it occurred to me that it might be
nice to animate the page number during the search and see if that gave
enought feedback (kinda like Adobe Acrobat does).
So I set the title on my page number thus, each time through my search loop:
- (void) setPageNumber {
NSMutableString *page = [[[NSMutableString alloc] init] autorelease];
[page appendString: @"Page: "];
[page appendString: [[NSNumber numberWithInt: m_currentPage+1] stringValue]];
[[pageNumber cell] setTitle: page];
}
Here page number is a read only NSTextField.
Unfortunately, nothing I seem to do actually causes the page number to
update until the search is over!
This is hardly surprising, one assumes I'm starving some update thread
somewhere (I've done enough Java programming to know all about that!)
but even if I get the current thread (in the search loop) and ask it to
sleep for as much as 1 second per iteration, it has no effect.
Is there a way to get the effect I want?
--
AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside
I think we finally found the killer app for Flash: animated stick men