Re: [Pyobjc-dev] applicationShouldOpenUntitledFile_
Brought to you by:
ronaldoussoren
From: <bb...@ma...> - 2003-02-02 06:00:51
|
On Saturday, Feb 1, 2003, at 23:34 US/Eastern, Mitch Chapman wrote: > I'm not sure if this is a bug or if I've screwed up my installation. > > Using the CVS PyObjC (updated about 1930 MST today), with its > slightly-modified project templates (see below) installed under > ~/Developer, > I created a new Cocoa-Python Document-based application. Then in > MyAppDelegate.py I changed the return value from YES to NO. When the > application started it opened an Untitled document, despite the changed > return value. > > I'm having similar problems convincing the application that > openFile_ofType_ > is successful -- I keep getting "Can't open file <pathname>" dialogs. > > Thanks for any hints. Please be gentle with the clue stick :) Very easy fix and not at all obvious. The problem is that there is no way for the bridge to know that your implementation of the method should return BOOL. So, you either have to tell the bridge that your method returns a BOOL through the use of the objc.selector() function or, better yet, declare that your class implements the informal NSApplication delegate protocol. That is, change your class declaration to something like... class MyAppDelegate(NSObject, NSApplicationDelegate): .... ... and the bridge will automatically make sure that the signatures-- that the types of the arguments and return values-- of the methods that act as the app delegate are correct. Similar mechanisms also exist for window delegates, table data sources, dragging destinations/sources, and a number of other collections of methods. It also works with the AutoBaseClass mechanism. b.bum |