Two text fields. One for input file, the other for output directory. Both with a browse button to set the contents of the text field.
This is the issue I’m running into:
I can test on click theObject for which browse button is clicked. But you must call on panel ended to set the result from the open panel and you can’t do this within any other event block.
so things like (pseudo code):
on clicked theObject
display panel
if theObject is browseOne
on panel ended
set result to textFieldOne
end panel ended
end if
end clicked
It also doesn’t pause at the panel event waiting for a return…so the following doesn’t work eithe r(psuedo code)
on clicked browseOne
display open panel
set textFieldOne to result
end on clicked
on panel ended
set result to selected file
end panel ended
on clicked theObject
if theObject's name is "blah" then
tell open panel
set can choose directories to true -- or false
set can choose files to true -- or false
set allows multiple selection to false -- or true
end tell
display open panel
end if
end clicked
on panel ended theObject with result withResult
-- The open and save panels set `withResult` to 0 if the user canceled
if withResult is 1 then
set content of text field "something1" of window "whatever" to (path name of open panel)
set content of text field "something2" of window "whatever" to (path name of open panel)
end if
end panel ended
Sorry krunk, I misunderstood you. This sounds similar to this thread: ‘printout’ window
It sounds like you used something like this, which is good.
global usingOpenPanelFor
on clicked theObject
if theObject's name is "input" or theObject's name is "output" then
set usingOpenPanelFor to theObject's name
tell open panel
set can choose directories to true -- or false
set can choose files to true -- or false
set allows multiple selection to false -- or true
end tell
display open panel
end if
end clicked
on panel ended theObject with result withResult
-- The open and save panels set `withResult` to 0 if the user canceled
if withResult is 1 then
set content of text field usingOpenPanelFor of window "whatever" to (path name of open panel)
end if
end panel ended
In my case, I used the “on end editing” handler rather than the “panel ended” to register the changes in the text field of my attached panel. jobu suggested using “on changed” handler and that should work too.
As regards pausing the panel to wait, I used a global boolean flag that could be tested and based on the existing condition of the flag, allows my program to exit the attached panel so that the edited text could be processed.
I am not sure if we have the same problem, Still, I do hope that the above could give you some leads.