Progress Bar used by many script

Is it possible to create one window with a progress bar and use it in many script ?

Should i declare everytime outlet in the script or can i use a global binding (like application) ?

thanks

I believe you can do that.
I am not sure what you mean by global property, or what that would be, but you can bind your window to a property, e.g myProgressThing, in the App Delegate script, and then you can access that property from other scripts like this:

set myProgressThing to current application's NSApp's delegate()'s myProgressThing()

May be it works but I don’t know how to use it really.

So i tried : in the app delegate script, i mean the main)
i’ve a main window property menuWindow : missing value – outlet

property menuWindow : missing value -- outlet

in the same window, i’ve a progress barre

property incrementBarreProgress : 0 -- binding property
property maxBarreProgress : 10 -- binding property

set incrementBarreProgress to current application's NSApp's delegate()'s incrementBarreProgress()
set maxBarreProgress to current application's NSApp's delegate()'s maxBarreProgress()

In an other script, i want to call the progress barre, so i define again :

set incrementBarreProgress to current application's NSApp's delegate()'s incrementBarreProgress()
set maxBarreProgress to current application's NSApp's delegate()'s maxBarreProgress()

and make a routine


on barreProgression_(i)
		set my incrementBarreProgress to i as integer
		tell menuWindow to displayIfNeeded()
		do shell script "sleep 0.2"
	end barreProgression_

But it gives me an error :
“setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key incrementBarreProgress.”

So what’s wrong ?

When you call:

current application's NSApp's delegate()'s incrementBarreProgress()

what you get back is the value of that property.

You probably want to use something like:

current application's NSApp's delegate()'s setIncrementBarreProgress_(i)

Chrismacteam:
First of all, you don’t use the “NSApp’s delegate()…” in the app delegate script; it’s meant to be used in the other script. Those two lines are either meaningless or make circular references.

Second, I would rather bind to the progress bar, not to the value of the increment. Then use a method on it, see NSProgressIndicator, such as “incrementBy:” But this is merely a matter of taste perhaps. Shane just posted a suggestion in the case you really want to bind to the values rather than talking to the progress indicator. (At first I posted an answer before I saw Shane’s answer, then I deleted my post and wrote this instead.)

Third, I might have misunderstood you: I took for granted that the other script owned another nib file and was instantiated there, and that it was the reason for your question on how to access a common window defined elsewhere. However, maybe you only have one nib file? If so, there is no need at all to say “NSApp’s delegate()…” since then you can do as usual, namely bind the progress bar components to every script that needs it (via blue cubes whose classes is set to these other scripts).

Language confusion: is “barre” French for “bar”, or a misspelling?

:frowning: So now i’m starting to be lose

error : "[*** -[CPo_ToolBoxAppDelegate setincrementBarreProgress]: unrecognized selector sent to object <CPo_ToolBoxAppDelegate @0x2000edf00: OSAID(27)>
*** -[Cartouche currentDocCartouche:]: *** -[CPo_ToolBoxAppDelegate setincrementBarreProgress]: unrecognized selector sent to object <CPo_ToolBoxAppDelegate @0x2000edf00: OSAID(27)> (error -10000)
"

In main script (CPo_ToolBoxAppDelegate) :

	property incrementBarreProgress : 1 -- binding property
	property maxBarreProgress : 10 -- binding property

In other script (Cartouche) who call the main : no property declare

	on barreProgression_(i)
		log i
		--set my incrementBarreProgress to i as integer
		current application's NSApp's delegate()'s setincrementBarreProgress(i)
		tell menuWindow to displayIfNeeded()
		do shell script "sleep 0.2"
	end barreProgression_

is the problem coming because the two binding on main script ? or somewhere else ?

Yes i’m french, but i try to write in english so barre is the french word.

As you said, i have only 1 nib.

the max value and the value are binding with
property incrementBarreProgress : 1 – binding property
property maxBarreProgress : 10 – binding property
in the main script.

i understand that i can bind the progress bar via blue cube, but how can i change the value of it ?

May be i’m totally wrong and i need no binding at all. If yes what is the method ?

Watch your spelling, including underbars and capitalization! It is important.
Shane wrote: setIncrementBarreProgress_(i) whereas you used: setincrementBarreProgress(i), note capital I and the underbar

Of course the properties need to be either bound in IB via blue cubes, or you can use the “NSApp’s delegate()'s…” thing to get a reference to them.

Thanks a lot. You were right, my problem was with the “I” cap and the underscore

So to explain the final version :
in the main script

	-- IBoutlet --- Barre Progress -------------------------------
	property incrementBarreProgress : 0 -- binding property
	property maxBarreProgress : 10 -- binding property

in the other script :

	on barreProgression_(i)
		current application's NSApp's delegate()'s setIncrementBarreProgress_(i)
		--tell menuWindow to displayIfNeeded()
		do shell script "sleep 0.2"
	end barreProgression_