Dear intelligent people,
I am writing a small AS studio program in which I want to use a panel window or sheet.
In that panel I use a button, which has to work with a global variable from the main window and script.
The button’s applescript scope is set to the main script.
When I click the button though, it always shows me the default value of the property and not the one into which it has already been changed by actions in the main script. When I add a similar button to the main window, this does show the right updated version…
I will add some demo code, just have to make a cleaned example, but if someone already understands my problem and thinks to have a solution, feel welcome to post it here!
Thanks in advance,
Thomas
Edit: the demo code / removed all non-necessary stuff:
property myPath : (path to me)
property panelWIndow : missing value
property theDoubles : 3
property curConflictNr : null
on clicked theObject
if the name of theObject is "testBTN" then
duplicateOpenPanel()
else if the name of theObject is "testBTN2" then
testShowDoubles()
else if name of theObject is "useGbtn" then
testShowDoubles()
end if
end clicked
on panel ended thePanel with result theResult
end panel ended
on duplicateOpenPanel()
global curConflictNr
set myPath to (path to me as string)
set shellphp to POSIX path of file (myPath)
set theDoubles to do shell script ("php " & shellphp & "Contents/Resources/test.php")
display dialog theDoubles
if (theDoubles is "0") then
else
set curConflictNr to 1
if panelWIndow is equal to missing value then
set panelWIndow to window "duplicates"
end if
-- display panel panelWIndow attached to window "main" -- commented out in a try to see if it differed, no changes in results
display panelWIndow
tell panelWIndow
set content of text field "conflictStatus" to "Conflict " & curConflictNr & " of " & (count paragraphs of theDoubles)
end tell
end if
end duplicateOpenPanel
on testShowDoubles()
display dialog (theDoubles)
end testShowDoubles
The setup:
- Main window
±- button “testBTN”
±- button “testBTN2” - “Duplicates” NSPanel (in same nib, was in separate nib before, same results)
±- button “useGbtn”
Results:
when I click the testBTN2, it will show the correct contents of theDoubles (tab-separated text)
when I click the useGbtn, it will show the default value of the propery (3)
if I make the default propery null, then it will show some number, always the same, looking like a epoch timestamp.