osx - on MAC, I have to show a busy window with a cancel button and spinner -
on mac using xcode , objective-c, need display little "busy" window containing spinner , cancel button. prevent user doing else in application until finished long operation, if click cancel should stop operation.
i tried creating simple nswindowcontroller based window cancel button , making window modal, so.... -(void) start_long_operation { ... ... [self showbusy]; return; // homecoming go on long operation } // throw "busy" dialog box user cant until done -(void) showbusy { busynswindow *loadingview = [[loadingview alloc] initwithwindownibname:@"loadingview"]; [[nsapplication sharedapplication] runmodalforwindow:loadingview.window]; } // if cancel clicked, signal stop long operation, close "busy" dialog box -(ibaction) cancel { // cancel clicked within "busy" dialog box signal process stop long operation }
but happens stays within [[nsapplication sharedapplication] runmodalforwindow:loadingview.window] , doesnt return. want homecoming can go on long processing while "busy" dialog box up, wont work.
anybody knows how create little "busy" window has cancel button , spinner, preventing user clicking outside window until operation completed, allowing rest of programme go on can process long operation?
-rough_neck
long operations should never done on main thread anyway. utilize nsoperation
, nsoperationqueue
long-running operation, runs in background, , modal window work fine.
another alternative, it's much less convenient, utilize "modal session". see -beginmodalsessionforwindow:
, -runmodalsession:
, , -endmodalsession:
methods of nsapplication
. that, you'd have break long-running operation quick-running steps can invoked sequentially.
osx spinner nswindowcontroller
No comments:
Post a Comment