gen2brain / dlgs

Go cross-platform library for displaying dialogs and input boxes
BSD 2-Clause "Simplified" License
385 stars 44 forks source link

MacOS not working #4

Open sooslaca opened 6 years ago

sooslaca commented 6 years ago

Sorry, dunno how to open a pull request.

message_darwin.go line 61:

Change From: tell application "System Events" to display dialog .... To: display dialog ...

Otherwise you get (because of "with icon" part): 28:115: execution error: System Events got an error: Can’t make application "System Events" into type number or string. (-1700)

https://docwhat.org/mac-shell-dialogs

gen2brain commented 6 years ago

Hey, there was this pull request https://github.com/gen2brain/dlgs/pull/3 , so not sure what is the correct fix here @leonjza .

leonjza commented 6 years ago

Hmm, problem with not "telling" a specific application is that when you are not in a logged in user context, there will be no dialog at all.

gen2brain commented 6 years ago

@sooslaca why do you think it is because of "with icon" part, it works ok without it? I don't use macOS so I don't really understand that well all those telling, there was this issue with color selector https://github.com/gen2brain/dlgs/issues/1 where app was hanging until you "tell".

sooslaca commented 6 years ago

hey, I'm not a MAC guru either, but here is the proof from Terminal app:

WITH ICON:

MACMACHINE:~ user$ osascript -e 'tell app "System Events" to display dialog "A stop dialog with only one button." buttons "OK" default button 1 with title "and a title" with icon stop'
28:150: execution error: System Events got an error: Can’t make application "System Events" into type number or string. (-1700)

(dialog is NOT displayed)

WITHOUT ICON:

MACMACHINE:~ user$ osascript -e 'tell app "System Events" to display dialog "A stop dialog with only one button." buttons "OK" default button 1 with title "and a title"'
button returned:OK

(after this dialog displays)

OS VERSION:

MACMACHINE:~ user$ uname -a
Darwin MACMACHINE 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
sooslaca commented 6 years ago

Also works in terminal if I leave out 'tell app "System Events"

MACMACHINE:~ user$ osascript -e 'display dialog "A stop dialog with only one button." buttons "OK" default button 1 with title "and a title" with icon stop'
button returned:OK