Native Open URL

Mac OSX specific forum
mrbungle
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Dec 30, 2020 3:18 am

Native Open URL

Post by mrbungle »

One can use the RunProgram() command to open a URL, but sometimes using a native function is faster. This will allow you to open any URL from your PB apps:

Code: Select all

Procedure OpenURL(URL.s)
  Protected NSURL = CocoaMessage(0, 0, "NSURL URLWithString:$", @URL)
  If NSURL
    Protected workspace = CocoaMessage(0, 0, "NSWorkspace sharedWorkspace")
    CocoaMessage(0, workspace, "openURL:", NSURL)
  EndIf
EndProcedure

Foo.s = "https://www.google.com")
OpenURL(Foo)
Quin
Addict
Addict
Posts: 1155
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Native Open URL

Post by Quin »

Just replaced RunProgram in my Mac app with this, and it works beautifully. Thanks!
mrbungle
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Dec 30, 2020 3:18 am

Re: Native Open URL

Post by mrbungle »

You're welcome
Post Reply