Saturday, December 16, 2017

#1 2015-10-09 06:27:43 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Progress bar is broken in ElCoyote 10.11

Hi all.

Any body know, what happened with progress indicator in these El Coyote OSX? mad

i look in what's new, but there say nothing about, displayIfNeeded() present... but progress bar lost animations.

Best regards, Alex.


Regards, Alex

Offline

 

#2 2015-10-09 07:06:35 am

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

Re: Progress bar is broken in ElCoyote 10.11

It's just part of the redesign. Copy a large file in the Finder and you'll see the same thing: there's a very subtle animation before the copying starts, then none that I can discern.


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

Offline

 

#3 2015-10-09 07:17:53 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Progress bar is broken in ElCoyote 10.11

Nice redesign lol
First time show initial message, then "App is idle..." and finally – label about last file from queue, full progress bar.
Any idea how to make it work?


Regards, Alex

Offline

 

#4 2015-10-09 07:34:14 am

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

Re: Progress bar is broken in ElCoyote 10.11

That sounds like a different issue. Have you tried the method outlined in chapter 13 of my book?


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

Offline

 

#5 2015-10-09 07:44:50 am

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

Re: Progress bar is broken in ElCoyote 10.11

Alex,

I'm assuming you're telling the window to displayIfNeeded(). As a quick hack, try adding this after that line:

Applescript:

delay 0.0001

It works here with 10.11, and it shouldn't cause problems with earlier versions -- although you'll need to check.


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

Offline

 

#6 2015-10-09 08:01:30 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Progress bar is broken in ElCoyote 10.11

Thanks, Shane

Sample project from chapter 13 work well. Now I need to move it in my projects.

smile


Regards, Alex

Offline

 

#7 2015-10-12 02:05:26 am

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

Re: Progress bar is broken in ElCoyote 10.11

FWIW, I've added an update to the book's errata page on the topic:

www.macosxautomation.com/applescript/apps/errata.html


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

Offline

 

#8 2015-10-12 02:56:27 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Progress bar is broken in ElCoyote 10.11

Hi, Shane.

I did some changes in my project with samples from Ch. 13 and discovered one problem – progress bar shows with one step delay.

Applescript:


   -- the original doProcess_ handler has been split into four
   on doProcess:sender -- STEP 1. Call and initialize progressbar
       windowProgress's makeKeyAndOrderFront:me
       set my isIdle to false -- app is no longer idle
       set aFile to item 1 of vectorFilePosixPaths
       set my vectorFileName to (its nameFromPath:(POSIX path of aFile)) as text -- Initial file name for progress bar
       
       
       my performSelector:"doStartOfJob:" withObject:1 afterDelay:0 -- call next handler as new event
   end doProcess:
   
   on doStartOfJob:n -- STEP 2. Refresh file name and show it
       set n to n as integer -- need to coerce because it's been passed via Cocoa
       set my statusMessage to "Processing number " & n
       set my theCounter to n
       
       set aFile to item n of vectorFilePosixPaths
       set my vectorFileName to (its nameFromPath:(POSIX path of aFile)) as text -- Current file name for progress bar
       (*    
       tell application "Finder"
           activate
           display dialog "vectorFileName: " & vectorFileName as text
       end tell
       
*)

       -- this where you would do your stuff
       my simulateJob:n -- simylate job with call "display dialog"
       --my workIllustrator:n
       
       my performSelector:"doRestOfJob:" withObject:n afterDelay:0 -- call next handler as new event
   end doStartOfJob:
   
   on doRestOfJob:n -- STEP 3. Loop if need
       set n to n as integer -- need to coerce because it's been passed via Cocoa
       current application's NSThread's sleepForTimeInterval:0.5
       if n < (vectorCount as integer) then
           my performSelector:"doStartOfJob:" withObject:(n + 1) afterDelay:0 -- call previous handler as new event
       else
           my performSelector:"cleanUp" withObject:(missing value) afterDelay:0 -- call next handler as new event
       end if
   end doRestOfJob:
   
   on cleanUp() -- STEP 4. Reset progress bar and stop process
       set my statusMessage to "Finished processing " & (vectorCount as integer) & " times."
       set my isIdle to true
   end cleanUp
   
   on simulateJob:n -- Simulate intense activity
       tell application "Finder"
           activate
           display dialog vectorFileName & " – " & n as text
       end tell
   end simulateJob:
   

When i start STEP 1. Show noting, progress window opens after the call and close the first dialog box, and show file and progress with one step later.


Regards, Alex

Offline

 

#9 2015-10-12 05:50:09 am

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

Re: Progress bar is broken in ElCoyote 10.11

I'm not sure of your problem -- the sample works OK. However, I suggest you follow the samples that don't have "as Steps" in their name. I suspect using the equivalent of doEventFetch() is going to be the only reliable way to deal with the changed updating behavior.


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

Offline

 

#10 2015-10-12 06:29:00 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Progress bar is broken in ElCoyote 10.11

Maybe, but i try to move progress bar to another window and have same issue – progress window show only after first step is done.
this Declarations – "makeKeyAndOrderFront:" and "orderFront:" don't show me progress window before any kind of stuff, whose called after.

Sorry for my english.


Regards, Alex

Offline

 

#11 2015-10-12 06:35:07 am

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

Re: Progress bar is broken in ElCoyote 10.11

Yes, I think you're going to have to call either doEventFetch() (or equivalent) or performSelector:withObject:afterDelay: at or very close to the point where you want something to appear or change on screen. That's an advantage of the doEventFetch() method, in that you can virtually throw it in anywhere.

It's a big change in behavior.

(Your English is fine...)


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

Offline

 

#12 2015-10-12 06:44:33 am

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

Re: Progress bar is broken in ElCoyote 10.11

Just to be clear, here is what I think will be the easiest and best solution, at least within an app delegate class:

* Find Myriad Helpers -- you can download it from my Web page.

* Drag the files ObjectWithFords.h and ObjectWithFords.m into the Navigation area of your project, clicking the Copy checkbox.

* In your app delegate file, where it says:

Applescript:

   property parent : class "NSObject"

change it to:

Applescript:

   property parent : class "ObjectWithFords"

That makes your app delegate inherit the methods of the ObjectWithFords class.

* Now, wherever you want to screen to be updated, use:

Applescript:

my fordEvent()


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

Offline

 

#13 2015-10-12 07:18:25 am

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

Re: Progress bar is broken in ElCoyote 10.11

And here's an alternative that seems to be working:

Where you use displayIfNeeded(), for example:

Applescript:

|window|'s displayIfNeeded()

change to:

Applescript:

|window|'s performSelectorOnMainThread:"displayIfNeeded" withObject:(missing value) waitUntilDone:true

I have only tried it one project, but it works there.


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

Offline

 

#14 2015-10-12 07:33:28 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2727
Website

Re: Progress bar is broken in ElCoyote 10.11

Shane Stanley wrote:

And here's an alternative that seems to be working:

Where you use displayIfNeeded(), for example:

Applescript:

|window|'s displayIfNeeded()


Don't you need to set the needsDisplay property to true, in order to make displayIfNeeded() to work? I never had to use that method, setting  the property to needsDisplay to true was always enough.

Offline

 

#15 2015-10-12 07:58:52 am

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

Re: Progress bar is broken in ElCoyote 10.11

DJ Bazzie Wazzie wrote:

Don't you need to set the needsDisplay property to true, in order to make displayIfNeeded() to work? I never had to use that method, setting  the property to needsDisplay to true was always enough.


it's a good thought. But up until 10.11, displayIfNeeded() alone was fine when the control was changed via bindings, as is the case here -- presumably the bindings mechanism marked the relevant controls as dirty.

In any event, adding setNeedsDisplay:true to the window's content view, either as well as or instead of displayIfNeeded(), doesn't seem to make any difference in this context (which is for updates within a repeat loop, so not at the end of an event).


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

Offline

 

#16 2015-10-12 09:47:37 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Progress bar is broken in ElCoyote 10.11

Thanks, Shane.

I'm sorry, i put my call handler in wrong place I should place caller in step 3, not in step 2. Now all work well with sample for Chapter 13. With steps and with step with cancel.


Regards, Alex

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)