openFiles (available since OS X 10.3) replaces using the openFile method. It allows for more convenient handling of multiple drops and knowing in advance how much files/folders are dropped instead of openFile with which you only get to respond to a single file/folder drop at a time. By default openFiles calls the newly added MacOpenFiles which calls MacOpenFile multiple times, so ordinarily the behaviour is backwards compatible (both on wxOSX Cocoa and Carbon).
The openFile instance method has been removed because it doesn't seem to be called anymore: neither when dropping a single file on the application in the dock or Finder nor when passed as a command-line argument.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68617
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
- Implement wxFileType::GetOpenCommand().
- wxGetOsVersion() now returns more sensible version numbers, e.g. 10 and 6
for OS X 10.6.
- 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.
virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
#endif
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) ;
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
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.
since command line arguments are used differently there.
You may use the wxCmdLineParser to parse command line arguments.
*/
virtual void MacNewFile();
*/
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.
/**
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.
- 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.
/**
Called in response of a "get-url" Apple event.
{
public:
#ifdef __WXMAC__
{
public:
#ifdef __WXMAC__
- virtual void MacOpenFile(const wxString & fileName );
+ virtual void MacOpenFiles(const wxArrayString & fileNames );
#endif
virtual bool OnInit();
#endif
virtual bool OnInit();
-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 */);
-// 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))
{
short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
{
wxString fName ;
FSRef theRef ;
wxString fName ;
FSRef theRef ;
+ wxArrayString fileNames;
for (i = 1; i <= itemsInList; i++)
{
AEGetNthPtr(
for (i = 1; i <= itemsInList; i++)
{
AEGetNthPtr(
(Ptr)&theRef, sizeof(theRef), &actualSize);
fName = wxMacFSRefToPath( &theRef ) ;
(Ptr)&theRef, sizeof(theRef), &actualSize);
fName = wxMacFSRefToPath( &theRef ) ;
+ MacOpenFiles(fileNames);
+
// Support Routines linking the Mac...File Calls to the Document Manager
//----------------------------------------------------------------------
// 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
void wxApp::MacOpenFile(const wxString & fileName )
{
#if wxUSE_DOC_VIEW_ARCHITECTURE
wxUnusedVar(application);
}
wxUnusedVar(application);
}
-- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename
+- (void)application:(NSApplication *)sender openFiles:(NSArray *)fileNames
- 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
}
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
#ifdef __WXMAC__
/// Respond to Apple Event for opening a document
#ifdef __WXMAC__
/// Respond to Apple Event for opening a document
-void hvApp::MacOpenFile(const wxString& filename)
+void hvApp::MacOpenFiles(const wxArrayString& fileNames)
- wxFileName fileName(filename);
+ wxFileName fileName(fileNames[0]);
m_helpController->AddBook(fileName);
m_helpController->DisplayContents();
}
m_helpController->AddBook(fileName);
m_helpController->DisplayContents();
}
#ifdef __WXMAC__
/// Respond to Apple Event for opening a document
#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
#endif
/// Prompt the user for a book to open