Progress bar not always in color

I have an app with a progress bar that runs during an “on open” handler.

There’s also a “settings” window that will only open it the app is launched from the Finder (not with “on open”). (Actually, it’s set to show in an “on activate” handler to prevent it from opening before the “on open” handler is accessed - this way my “on open” handler can flag the “settings” window to not show).

Here’s the problem:
If I drop files on the app while it is already open from a Finder launch, the progress bar is in color; otherwise, without first launching the app THEN dropping files on it in the Finder, the progress bar is greyed out.

What is the key to ensuring that the progress bar is always in color? Any suggestions are greatly apprecialted.

BTW, I’ve tried fooling with the window as a “panel” or “window”; tried making “key” or “main”; tried setting index of window to “1”; but as I’m still learning, I may not be doing some of these things correctly.



Try putting:

tell me
end tell

Before telling the progress bar to do anything.

Thanks Elijah,
But, it still behaves exactly as before.
Any other ideas?

well there is a setting to change a progress bar’s style if you look in the Xcode AS dictionary (via the script editor) but i once tried it and it did not work. but i might have done something incorrect. try it and let me know

the indicated part (and the relevant part in bold)…

When an application is in the background, the GUI elements are given a gray tint, so more than your progress bar should be gray (any buttons, the x - + gems in top left corner, etc). If this is the case, it’s just that your application is processing the files before processing the “activate” event it received.

If this bothers you, try something like this:

property queuedOpenFiles: {}
on open theseFiles
	-- add files to the open queue
	set the end of queuedOpenFiles to theseFiles
end open

on idle
	repeat with i in queuedOpenFiles
	end repeat
	set queuedOpenFiles to {}
	return 5
end idle

on processOneFile(theFile)
	-- do stuff on theFile
end processOneFile

Completely untested, but let me know if it works! Remember to connect the idle event handler in IB to the “File’s Owner” item. You might also want to skip processing the very first time the idle handler runs (have a boolean global idleHandlerWasCalled for example).

Thanks for the replies. Here’s where I’m at with this.

After some testing and experimenting I found that whenever an alert panel was presented, it, and - subsequent to dismissing the panel - the progress bar, showed in color. I created a new window for the progress bar using NSPanel instead of NSWindow and that seems to have solved the problem - so far. I’m still running tests.

The suggestion from “themacgeek” yielded for me the same results as his own - doesn’t work. Thanks for trying.

Regarding the post from “PCheese”, the way my files are processed I would have to do a bit of work to include the idle handler. However, I doubt that it would’ve improved anything since I’ve tried to send “activate” calls to the app in many places with no positive result. Also, the progress panel I’m using is informational only - it does not include the x - + gems (“Has Texture” is selected in IB) nor any buttons; although I suspect they, too, would be greyed out if they existed. And, since changing the type of window while keeping the code the same has fixed the problem, I’m further convinced that this was likely not an issue with “activate”.

I appreciate all the replies and hope that others can use this situation as a lesson. But I fear that there may be more to this than just changing the window to a panel - and perhaps I just got lucky. I remember doing some testing for progress bars in the past and when a similar problem arose, it occurred with both windows and panels.

If others have had similar issues with the progress bar and found solutions different from my own I’d still be interested in knowing what they are.

Thanks again to all.

Model: 2.5 dual G5
AppleScript: 2.0
Browser: Firefox 1.0.4
Operating System: Mac OS X (10.3.9)

You can set up your task to start when the window with the progress indicator becomes key. But then you have to add a variable that says it has started the task so that if a user clicks somewhere else and then back it doesnt try and start again.