Skip to main content
Solved

Display notification including a URL

  • March 22, 2012
  • 2 replies
  • 24 views

dpertschi
Forum|alt.badge.img+19

Can anyone give advice on how to display a dialog/notification to users which includes a clickable URL?

displayMessage and jamfHelper are not working out for me, unless I'm not using the right syntax or formatting. AppleScript?

thanks,
Darrin

Best answer by acidprime

So I created something like this, and just posted and open source version of it

You can find a compiled example below

external image link

https://github.com/acidprime/ClickDialog/downloads

It could be integrated into scripts like so

#!/bin/bash

declare -x ClickDialog="/Applications/ClickDialog.app/Contents/MacOS/ClickDialog"
if "$ClickDialog" ; then
        echo "User clicked OK"
else
        echo "User clicked cancel"
fi

Xcode Project (very basic 10 mins don't judge) below
https://github.com/acidprime/ClickDialog

Technical Details

Basically I just load a web.html file from the bundle ,matched the colors so it looks like a native element and then added a delegate method to catch the url click and redirect it to the default workspace. I added an "activate" and told it that it was a UI element so it will not show the dock icon, much like a display dialog in AppleScript

You can play with the Xcode project ( with no code changes ) if you want to make the window bigger ( in fact you can probably just edit the raw .xib file in interface builder

2 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • March 22, 2012

I'm not sure there's a way to do this outside of writing a custom app. I've tried, tried and tried again to get some way for clickable URLs inside dialogs and came up empty.
In my searching, I did find some kludgy methods posted on the interwebs, such as using Applescripts with buttons that when clicked on open a URL, or even showing a list inside an Applescript and allowing the user to choose one, which then opens it.
Neither method is very good, but I'm not sure how else it can be done. But I'd love to know too!


Forum|alt.badge.img+7
  • Contributor
  • 28 replies
  • Answer
  • March 29, 2012

So I created something like this, and just posted and open source version of it

You can find a compiled example below

external image link

https://github.com/acidprime/ClickDialog/downloads

It could be integrated into scripts like so

#!/bin/bash

declare -x ClickDialog="/Applications/ClickDialog.app/Contents/MacOS/ClickDialog"
if "$ClickDialog" ; then
        echo "User clicked OK"
else
        echo "User clicked cancel"
fi

Xcode Project (very basic 10 mins don't judge) below
https://github.com/acidprime/ClickDialog

Technical Details

Basically I just load a web.html file from the bundle ,matched the colors so it looks like a native element and then added a delegate method to catch the url click and redirect it to the default workspace. I added an "activate" and told it that it was a UI element so it will not show the dock icon, much like a display dialog in AppleScript

You can play with the Xcode project ( with no code changes ) if you want to make the window bigger ( in fact you can probably just edit the raw .xib file in interface builder