shithub: choc

Download patch

ref: 1db716fa176d6b611083feb61f8396d73f56a04a
parent: dd45fd96528fa67a866dfd174714eebb0f94af25
author: Simon Howard <[email protected]>
date: Fri Mar 16 19:41:44 EDT 2018

textscreen: Simplify AppleScript for fileselect.

Since macOS 10.9 it is no longer to "tell an application" in order
to display pop-up UI elements like the file select dialogs. Quote:

> osascript(1) is now a “UI element” process and can therefore display
> its own UI, such as using display dialog; telling another application
> such as System Events is no longer necessary. [12365409]

As well as simplifying the wrapper this also fixes some issues with the
pop-up dialogs where window focus was getting messed up after selecting
a file.

--- a/textscreen/txt_fileselect.c
+++ b/textscreen/txt_fileselect.c
@@ -331,13 +331,7 @@
 // an Objective C dependency. This is rather silly.
 
 // Printf format string for the "wrapper" portion of the AppleScript:
-
-#define APPLESCRIPT_WRAPPER \
-    "tell application (path to frontmost application as text)\n" \
-    "    activate\n" \
-    "    set theFile to (%s)\n" \
-    "    copy POSIX path of theFile to stdout\n" \
-    "end tell\n"
+#define APPLESCRIPT_WRAPPER "copy POSIX path of (%s) to stdout"
 
 static char *EscapedString(char *s)
 {