Added NSApplicationDelegate's openFiles for wxOSX-Cocoa.
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
This commit is contained in:
parent
af9c02ce20
commit
ee7553e935
@ -459,6 +459,7 @@ OSX:
|
||||
- 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:
|
||||
|
||||
|
@ -122,7 +122,10 @@ public:
|
||||
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) ;
|
||||
|
@ -569,7 +569,7 @@ public:
|
||||
|
||||
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.
|
||||
@ -802,16 +802,35 @@ public:
|
||||
*/
|
||||
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.
|
||||
|
@ -143,7 +143,7 @@ class wxMediaPlayerApp : public wxApp
|
||||
{
|
||||
public:
|
||||
#ifdef __WXMAC__
|
||||
virtual void MacOpenFile(const wxString & fileName );
|
||||
virtual void MacOpenFiles(const wxArrayString & fileNames );
|
||||
#endif
|
||||
|
||||
virtual bool OnInit();
|
||||
@ -463,10 +463,10 @@ bool wxMediaPlayerApp::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__
|
||||
|
@ -130,7 +130,7 @@ pascal OSErr AEHandleGURL( const AppleEvent *event , AppleEvent *reply , SRefCon
|
||||
}
|
||||
|
||||
|
||||
// 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))
|
||||
{
|
||||
@ -158,6 +158,7 @@ short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
|
||||
wxString fName ;
|
||||
FSRef theRef ;
|
||||
|
||||
wxArrayString fileNames;
|
||||
for (i = 1; i <= itemsInList; i++)
|
||||
{
|
||||
AEGetNthPtr(
|
||||
@ -165,9 +166,11 @@ short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
|
||||
(Ptr)&theRef, sizeof(theRef), &actualSize);
|
||||
fName = wxMacFSRefToPath( &theRef ) ;
|
||||
|
||||
MacOpenFile(fName);
|
||||
fileNames.Add(fName);
|
||||
}
|
||||
|
||||
MacOpenFiles(fileNames);
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
@ -274,6 +277,16 @@ short wxApp::MacHandleAERApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNU
|
||||
// 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
|
||||
|
@ -55,12 +55,18 @@ void wxBell()
|
||||
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
|
||||
|
@ -279,10 +279,10 @@ bool hvApp::OpenBook(wxHtmlHelpController* controller)
|
||||
|
||||
#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();
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
|
||||
#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
|
||||
|
Loading…
Reference in New Issue
Block a user