- Implement wxFileType::GetOpenCommand().
- wxGetOsVersion() now returns more sensible version numbers, e.g. 10 and 6
for OS X 10.6.
+- Added wxApp::MacOpenFiles and deprecated wxApp::MacOpenFile.
GTK:
virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
#endif
- // in response of an open-document apple event
+ // in response of an openFiles message with Cocoa and an
+ // open-document apple event with Carbon
+ virtual void MacOpenFiles(const wxArrayString &fileNames) ;
+ // called by MacOpenFiles for each file.
virtual void MacOpenFile(const wxString &fileName) ;
// in response of a get-url apple event
virtual void MacOpenURL(const wxString &url) ;
Under Windows and Linux/Unix, you should parse the command line
arguments and check for files to be opened when starting your
- application. Under OS X, you need to override MacOpenFile()
+ application. Under OS X, you need to override MacOpenFiles()
since command line arguments are used differently there.
You may use the wxCmdLineParser to parse command line arguments.
*/
virtual void MacNewFile();
+ /**
+ Called in response of an openFiles message with Cocoa, or an
+ "open-document" Apple event with Carbon.
+
+ You need to override this method in order to open one or more document
+ files after the user double clicked on it or if the files and/or
+ folders were dropped on either the application in the dock or the
+ application icon in Finder.
+
+ By default this method calls MacOpenFile for each file/folder.
+
+ @onlyfor{wxosx}
+
+ @since 2.9.3
+ */
+ virtual void MacOpenFiles(const wxArrayString& fileNames);
+
/**
Called in response of an "open-document" Apple event.
- You need to override this method in order to open a document file after the
- user double clicked on it or if the document file was dropped on either the
- running application or the application icon in Finder.
+ @deprecated
+ This function is kept mostly for backwards compatibility. Please
+ override wxApp::MacOpenFiles method instead in any new code.
@onlyfor{wxosx}
*/
- virtual void MacOpenFile(const wxString& fileName);
+ wxDEPRECATED_BUT_USED_INTERNALLY(
+ virtual void MacOpenFile(const wxString& fileName)
+ );
/**
Called in response of a "get-url" Apple event.
{
public:
#ifdef __WXMAC__
- virtual void MacOpenFile(const wxString & fileName );
+ virtual void MacOpenFiles(const wxArrayString & fileNames );
#endif
virtual bool OnInit();
#ifdef __WXMAC__
-void wxMediaPlayerApp::MacOpenFile(const wxString & fileName )
+void wxMediaPlayerApp::MacOpenFiles(const wxArrayString & fileNames )
{
- // Called when a user drags a file over our app
- m_frame->DoOpenFile(fileName, true /* new page */);
+ // Called when a user drags files over our app
+ m_frame->DoOpenFile(fileNames[0], true /* new page */);
}
#endif // __WXMAC__
}
-// AEODoc Calls MacOpenFile on each of the files passed
+// AEODoc Calls MacOpenFiles with all of the files passed
short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
{
wxString fName ;
FSRef theRef ;
+ wxArrayString fileNames;
for (i = 1; i <= itemsInList; i++)
{
AEGetNthPtr(
(Ptr)&theRef, sizeof(theRef), &actualSize);
fName = wxMacFSRefToPath( &theRef ) ;
- MacOpenFile(fName);
+ fileNames.Add(fName);
}
+ MacOpenFiles(fileNames);
+
return noErr;
}
// Support Routines linking the Mac...File Calls to the Document Manager
//----------------------------------------------------------------------
+void wxApp::MacOpenFiles(const wxArrayString & fileNames )
+{
+ size_t i;
+ const size_t fileCount = fileNames.GetCount();
+ for (i = 0; i < fileCount; i++)
+ {
+ MacOpenFile(fileNames[i]);
+ }
+}
+
void wxApp::MacOpenFile(const wxString & fileName )
{
#if wxUSE_DOC_VIEW_ARCHITECTURE
wxUnusedVar(application);
}
-- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename
+- (void)application:(NSApplication *)sender openFiles:(NSArray *)fileNames
{
wxUnusedVar(sender);
- wxCFStringRef cf(wxCFRetain(filename));
- wxTheApp->MacOpenFile(cf.AsString()) ;
- return YES;
+ wxArrayString fileList;
+ size_t i;
+ const size_t count = [fileNames count];
+ for (i = 0; i < count; i++)
+ {
+ fileList.Add( wxCFStringRef::AsString([fileNames objectAtIndex:i]) );
+ }
+
+ wxTheApp->MacOpenFiles(fileList);
}
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
#ifdef __WXMAC__
/// Respond to Apple Event for opening a document
-void hvApp::MacOpenFile(const wxString& filename)
+void hvApp::MacOpenFiles(const wxArrayString& fileNames)
{
wxBusyCursor bcur;
- wxFileName fileName(filename);
+ wxFileName fileName(fileNames[0]);
m_helpController->AddBook(fileName);
m_helpController->DisplayContents();
}
#ifdef __WXMAC__
/// Respond to Apple Event for opening a document
- virtual void MacOpenFile(const wxString& filename);
+ virtual void MacOpenFiles(const wxArrayString& fileNames);
#endif
/// Prompt the user for a book to open