Animating a NSProgressIndicator
Animating a NSProgressIndicator
- Subject: Animating a NSProgressIndicator
- From: email@hidden
- Date: Mon, 13 Jun 2011 09:48:12 -0500
I've got a sample project demonstrating the problem at:
https://files.me.com/ericgorr/vboa2p
(if for some reason you cannot access it, let me know and I'll send it
direct...it's only ~39k.)
If you run the application, pressing the Start Code Loop or Start Draw
Loop buttons, will require a force quit of the app…they will start an
infinite loop simulating a long process which I have no control over.
When you run the application, press the Start Anim button. This will
start the progress indicator animating.
Start Code Loop simply calls a method which just has while(1){}. After
pressing this button, you will notice that the progress indicator
continues to animate.
On the window, I have a custom NSView called MyClass. This view has a
property called infiniteLoopInDraw. If this property is true and the
view tries to draw itself, it will start executing while(1){}.
Start Draw Loop calls a method which sets infiniteLoopInDraw to YES and
tells MyClass to redraw. The moment it starts drawing, the animation on
the progress indicator stops.
What I believe is going on is that the drawing focus is locked on that
view. No other view on the window can draw and that includes the
progress indicator. Am I correct on this?
One obvious solution is to rearchitect the code to move the long
progress outside of the draw code and this is what I will likely end up
doing. Although, such a solution may not always be possible.
Another solution I found would be to place the progress indicator on a
separate window. This allows it to continue animating regardless of what
is going on in the main window. One could then simulate the progress bar
being on the main window by using a custom window which is the exact
size of the progress indicator and positioning it properly.
Perhaps it would be possible to roll my own indeterminate progress
indicator, but I am not certain how I would get around the drawing
issue. Any thoughts on this?
But, the primary thing I would like to know is whether or not I can
make the progress bar animate while the while(1){} loop is running
inside of the drawRect: method of MyClass without using an additional
window. While I wrote the infinite loop as while(1){}, which would allow
me to insert my own code into the while loop and may allow the progress
indicator to animate, in the real case, I do not have the ability to
modify the code executing the long process.
Thank you
-- Eric
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden