From: David Elliott Date: Tue, 8 May 2007 19:37:06 +0000 (+0000) Subject: Provide wxLaunchDefaultBrowser implementation for wxCocoa. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4263bab00e05dfe9af724d9b5695826976aec08c Provide wxLaunchDefaultBrowser implementation for wxCocoa. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45892 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/cocoa/utils.mm b/src/cocoa/utils.mm index a2ae48aa1a..f4acf49cb8 100644 --- a/src/cocoa/utils.mm +++ b/src/cocoa/utils.mm @@ -27,6 +27,11 @@ #include #include +#include "wx/cocoa/string.h" + +#import +#import + void wxDisplaySize(int *width, int *height) { // TODO @@ -97,6 +102,13 @@ void wxBell() // TODO } +// Private helper method for wxLaunchDefaultBrowser +bool wxCocoaLaunchDefaultBrowser(const wxString& url, int flags) +{ + // NOTE: We ignore the flags + return [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:wxNSStringWithWxString(url)]] != NO; +} + #if 0 // DFE: These aren't even implemented by wxGTK, and no wxWidgets code calls // them. If someone needs them, then they'll get a link error diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index abc3d00ecf..55b70aed84 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -678,6 +678,11 @@ wxRegisterId (long id) // Launch default browser // ---------------------------------------------------------------------------- +#ifdef __WXCOCOA__ +// Private method in Objective-C++ source file. +bool wxCocoaLaunchDefaultBrowser(const wxString& url, int flags); +#endif + bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags) { wxUnusedVar(flags); @@ -778,6 +783,10 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags) #endif // __WXDEBUG__ return true; } +#elif defined(__WXCOCOA__) + // NOTE: We need to call the real implementation from src/cocoa/utils.mm + // because the code must use Objective-C features. + return wxCocoaLaunchDefaultBrowser(url, flags); #elif defined(__WXMAC__) OSStatus err; ICInstance inst;