Native Open URL

Mac OSX specific forum
mrbungle
Enthusiast
Enthusiast
Posts: 162
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)