Thursday, December 14, 2017

#1 2017-09-06 09:32:25 am

SunnyFrinton
Member
Registered: 2012-09-13
Posts: 19

Update a window from inside a loop

I want to read a text file to produce a breakdown of certain categories by year for the last 5 years but the file is large and takes time to display the complete window. The program loops through all the data accumulating totals (file is in year sequence) so is it possible to update the window showing each year as it completes from within the loop. Hope this makes sense, my expertise in ApplescriptObjC is limited, I've only ever written projects where you hit a push button to display a window. Have tried displayIfNeeded() but no solution. Any guidance would be gratefully received!


Filed under: xcode, AppleScriptObjC

Offline

 

#2 2017-09-06 06:28:05 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Update a window from inside a loop

You need to force the run loop to run each time. Try calling this handler when you want the screen to update:

Applescript:

on doEventFetch()
   repeat
       set theEvent to current application's NSApp's nextEventMatchingMask:((current application's NSLeftMouseDownMask) + (get current application's NSKeyDownMask)) untilDate:(missing value) inMode:(current application's NSEventTrackingRunLoopMode) dequeue:true
       if theEvent is missing value then
           exit repeat
       else
           current application's NSApp's sendEvent:theEvent
       end if
   end repeat
end doEventFetch


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2017-09-07 05:21:27 am

SunnyFrinton
Member
Registered: 2012-09-13
Posts: 19

Re: Update a window from inside a loop

Hi Shane
Many thanks for reply, however, I have no idea what the handler does!!
Do I have to replace missing value with a value, if so, what?
Sorry to be dense but this is way outside my comfort zone, perhaps I should add a push button to display each year rather than wait untill all years have been accumulated.

Offline

 

#4 2017-09-07 08:54:37 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Update a window from inside a loop

You use the handler as-is — just call it every time you want the display to update.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#5 2017-09-08 10:47:34 am

SunnyFrinton
Member
Registered: 2012-09-13
Posts: 19

Re: Update a window from inside a loop

Many thanks, works exactly as required, all I have to do now is understand how it does it!!!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)