For the test script and the applet I’ve been working on I pasted the script into a new document and saved as an enhanced app.
I’ll try the sample you provided.
If I still see issues I’ll post the files and a movie.
For the test script and the applet I’ve been working on I pasted the script into a new document and saved as an enhanced app.
I’ll try the sample you provided.
If I still see issues I’ll post the files and a movie.
This ain’t right, Mark.
Your open handler is calling the Run handler. They should be separate, as they have been in previous Enhanced Applets and in Apple’s applet.
Files drag and dropped on the icon or in the window should simply cause it to beep and not invoke the run handler.
That should behave the same way as dragging files onto the UI.
Another thing I just noticed is that the title for the Choose From list dialog doesn’t display anywhere.
Other than that, it seems to be working better.
Here is a movie that illustrates the problems. I added some code to your sample to make it clear where the issues are. I’ve also included all the Applets referenced in the movie.
These are the issues in the current version of the enhanced applet shell:
The Run handler is invoked after the open handler stops if the open handler was invoked by drag and drop on the icon in the finder. It doesn’t happen if the open handler is called from search or dropping icons on the window.
My versions of the script don’t work and I don’t know why. After they run I can’t use the search or drag and drop in the menu.
Titles don’t display in Choose From List or Display Dialog
The OK button doesn’t highlight unless a Choose From List selection is made even when empty selections allowed is true.
→ Script Debugger: 8.0.3 (8A41)
→ Mac OS: 11.6 (20G165)
And here’s another twist. In response to another question I turned on Show Startup Screen on Mark’sDemo.app and it did not execute the run handler after the open handler when Icons were dropped on it.
@alldritt : I can confirm the behavior unfortunately. In the run handler I add a preference menu handler and read the settings. The latter are not present in this case and I get an error message “The variable … is not defined.”
Would it be possible for this use case to introduce a “Load” handler that is called before all other handlers, if it is present. The Rum and Open handlers already has certain functions in an applet.
I think we can do this in plain AppleScript without introducing new handlers:
property isLoaded: false
on load()
if not isLoaded then
...
set isLoaded to true
end
end
on run
load()
...
end
on open theFiles
load()
...
end
When I resolve the bug where the on run
handler is invoked after the on open
handler is called, you’ll only get the on run
call once. If the user launches the droplet by dropping files on it in the Finder, the on run
hander is not invoked before the on open
handler is invoked to handle the dropped files.
Please see the 8A42 build:
This is exactly how I solved it .
This was not possible before version 8.0.3, because the droplet state was not preserved if you had executed any code in the Run handler.
Thanks again for the changes in version 8.0.3!
Definitely progress, but still a couple issues.
With my Versions script, if I double click the icon it launches and executes the run handler. After that it remains in an unusable state, where search and drag and drop on the window don’t work.
Also, if I drag and drop on the icon it works, and when it’s done executing I can drag and drop on the window and search works.
I still have to click the Quit button twice.
Are you in the mood for a feature request? When it’s in the search/drop state would it be possible to have another option that would invoke the run handler (or any handler, really)?
→ Script Debugger: 8.0.3 (8A42)
→ Mac OS: 11.6 (20G165)
I cannot reproduce the filature you describe with my test script:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
property appletDropName : "Drag and drop files here" -- text prompt for drop tab
property appletDropImage : missing value -- name of image to appear on drop tab
property appletSearchName : "Search for files" -- text prompt for search tab
property appletSearchImage : missing value -- name of image to appear on search tab
on run
set listOfFileNames to {1, 2, 3, 4, 5, 6}
set userChoice to choose from list listOfFileNames ¬
with title ("Enhanced Droplet Test") ¬
with prompt ("List of names of files in open handler") ¬
default items 1 ¬
OK button name ("OK") ¬
cancel button name ("Done") ¬
multiple selections allowed true ¬
with empty selection allowed
end run
on open theFiles
beep
end open
on quit
try
continue quit
end try
end quit
on appletFileIsAcceptable(theFile)
return true
end appletFileIsAcceptable
When I launch the script it runs and then I can drop files.
I saved your script as is. When run after it runs it’s in the Drop/search mode.
If I drop an Icon on the window it works.
Search doesn’t work.
If I change the Bundle & Export settings, adding scptd and app save and quit the script, then when I run the script it runs but when I drop an icon on the window it doesn’t work. Search doesn’t work either.
In both cases, if I launch it by dropping an icon on it’s icon it works, and after it executes Search and Drag and Drop on the window doesn’t work.
Thanks Mark, Dialog Toolkit seems to work well. That’s great. I considered using it but first I wanted to start simple. So, that was a bad idea.
@estockly Do you use the Beta 8.0.3? In 8.0.2 it does not work.
So far, so good!
I’ve duplicated each of the test apps and they seem to work fine. Next I’ll try the full application.
Thanks
→ Script Debugger 8.0.3 (8A46)
→ Mac OS 11.6.1 (20G224)
This seems to have resolved all the issues. Very cool.
But I do have one question. Did the “Quit” button used to appear when the window was in drop mode?
I see it in search mode, but not drop mode.
(If not, it may be better to have it there too so the user doesn’t have to switch modes to quit)
→ Script Debugger 8.0.3 (8A46)
→ Mac OS 11.6.1 (20G224)
The quit button never appeared in the drop window. I’ll file a note at our end, but there is always the menu command to quit the app.
Got it, I figured that out eventually.
Seems that all the issues have been resolved.
Here’s a new issue (new to me at least).
I have an enhanced applet that controls several apps including Pages.
After using it for a few weeks with no issues I added a UI command to select a menu item in Pages. Works just fine in SD, but in Enhanced App it failed saying the app didn’t have permission to control the mac, and it took me to the accessibility pane in the General Settings preferences. There was a list of apps that had been given permission to control the mac and a + button to add an app. I clicked the + and navigated to the enhanced app but it did not appear in the navigation dialog. The Apple applet in the same folder was there.
So then I saved the enhanced app as an Apple pplet, and tried to run that, and got the same dialog, but the newly saved applet was in the navigation window so I added that.
Here’s the weird thing. I then tried to run the enhanced applet version and this time it worked. The GUI stuff worked and the app name still isn’t listed in the accessibility pane. The bundle IDs and app names are different.
I don’t know if it’s a new issue or not (I rarely use GUI stuff) and don’t know if it’s related to SD version or OS version or something else.
Either way it seems to work and it’s not an applet I’m likely to distribute so my issue solved itself, I just don’t know how.
→ Mac OS: 14.6.1 (23G93)
→ Script Debugger 8.0.8 (8A80)
→ SD Notary 2 2.0 (102)
→ FastScripts 3.2.7 (1767)
Did you set an unique bundle ID with your extended applet?