Tuesday, January 23, 2018

#1 2011-02-20 04:35:40 am

Rebewslin
Member
From:: Berlin. Germany
Registered: 2010-04-11
Posts: 22

Panel with progress bar indicator at "on opened theObject"-Handler

Hi,

my little studio-app (basend on this example from "Fredo d;o)": http://macscripter.net/viewtopic.php?pid=61654#p61654) has an auto-start-feature:
After starting the program it shows an interruptable dialog for 10 seconds (Picture: http://dl.dropbox.com/u/154942/start_program.jpg). This works, but only with a cosmetically problem: After running the program it is starting in a "backround mode" (see the picture, program runs, but menu is from XCode), the button "Cancel" is not clickable. Only if I press the "ESC"-key when the panel runs, it comes to the foreground, the progress indicator stops and the button is clickable.

If I start the same code from inside an "on clicked theObject"-Handler it works fine. Seems that I cant start a panel with an progress bar from inside the "on opened theObject"-Handler.

I've no idea, which handler I've to use, hope for your support.

Here's the code:

Applescript:

on opened theObject
   tell window "windowProgress"
       set contents of text field "textfieldProgressTitre" to "Reportgenerator."
       set contents of text field "textfieldProgressInofs" to "Starting..."
       set contents of progress indicator "progressIndicator" to 0 -- Start value
   end tell
   display panel window "windowProgress" attached to window "windowMain" --of theObject
   tell me to activate
   delay 1
   tell window "windowProgress"
       tell progress indicator "progressIndicator" to set maximum value to 10
       tell progress indicator "progressIndicator" to set indeterminate to false
       repeat with a from 1 to 10
           set myseconds to 10 - a
           set contents of text field "textfieldProgressInofs" to "Start in " & myseconds & " seconds."
           tell progress indicator "progressIndicator" to increment by 1
           delay 1
       end repeat
   end tell
   close panel window "windowProgress"
   --main routine handler here--
end opened

Here's a sample project (only 53k to download),it shows the problem: http://dl.dropbox.com/u/154942/DisplayP … xample.zip

Greetings Rebewslin

Model: MacBook Late 2007
AppleScript: XCode 3.2.4
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)

Last edited by Rebewslin (2011-02-20 05:08:13 am)

Offline

 

#2 2011-02-20 01:26:37 pm

Rebewslin
Member
From:: Berlin. Germany
Registered: 2010-04-11
Posts: 22

Re: Panel with progress bar indicator at "on opened theObject"-Handler

Quick & dirty solution: I moved the code to the "on idle"-Handler. To prevent that the code runs again after the program was started I included a new variable.

This is the code:

Applescript:


property autostart : true

on idle
if autostart then
tell window "windowProgress"
set contents of text field "textfieldProgressTitre" to "Reportgenerator."
set contents of text field "textfieldProgressInofs" to "Starting..."
set contents of progress indicator "progressIndicator" to 0 -- Start value
end tell
display panel window "windowProgress" attached to window "windowMain" --of theObject
tell me to activate
delay 1
tell window "windowProgress"
tell progress indicator "progressIndicator" to set maximum value to 10
tell progress indicator "progressIndicator" to set indeterminate to false
repeat with a from 1 to 10
set myseconds to 10 - a
set contents of text field "textfieldProgressInofs" to "Start in " & myseconds & " seconds."
tell progress indicator "progressIndicator" to increment by 1
delay 1
end repeat
end tell
close panel window "windowProgress"
--main routine handler here--
set autostart to false
end if
end opened

That works fine!

Rebewslin

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)