Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!coherent!next!sstreep From: sstreep@next.com (Sam Streeper) Newsgroups: comp.sys.next Subject: Re: How do I interrupt my App? Message-ID: <283@next.com> Date: 7 Nov 90 03:58:59 GMT References: <1614@libra.cs.nps.navy.mil> Reply-To: sstreep@elvis.UUCP (My Account) Organization: NeXT, Inc. Lines: 49 In article <1614@libra.cs.nps.navy.mil> you write: >I'm polishing up a nifty App to submit to the sites, but I'm stuck on >one thing. > >Part of the App involves creating a (very) long list in a ScrollView. >I want to be able to stop the listing without crashing my App, once >I'm happy with how long the list is. Currently, there is a "Start" button >that starts the listing. I'd like to make it so that this button >turns into a "Stop" button while the list is going, so that if >I push it again, the method creating the list just stops, just like >ScorePlayer, for example, whose start button turns into a stop button. > Just in case no one else responds: Button objects recieve mouse down events from the event loop. If you run your code but never return to the event loop until you're done with your scroll method, no message will be sent to the button, so the button can't invoke its action method, which would presumably set a stop flag. I can think of 3 things you might do: 1) Have a 'scroll one step' method repeatedly invoked by a timed entry. See BreakApp in the developer demos for an example of a timed entry function. 2) Put the scrolling in a modal responder loop: NXModalSession session; [NXApp beginModalSession:&session for:theWindow]; for (;;) { if ([NXApp runModalSession:&session] != NX_RUNCONTINUES) break; /* scroll one line here... */ } [NXApp endModalSession:&session]; Then your button action method will send a 'stopModal' message. This is probably the easiest way to do what you want. 3) You might do this by peeking at the next event, either using the Application class methods or DPS functions. This certainly is not the best way to do this so I won't dig up an example. I hope I understood your question and answered it adequately. >_____________________________________________________________________ >Jeff & Tamara Adams (or at least one of us) -sam Opinions expressed here are my own. You can borrow them for a dollar.