Re: [Pyobjc-dev] Passing selectors as parameters
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-05-12 18:03:33
|
On Monday, May 12, 2003, at 10:01 Europe/Amsterdam, Sean Gilbertson wrote: > Hello all, > > I have an NSListView whose double-click actions I would like to > handle. NSListView.setDoubleAction_( action ) requires a selector. > My problem is that I'm not sure how to pass a method as a selector. I > would like to pass a class "instance" method (i.e. "def > didDoubleClick( self ):") that belongs to the class I use as the > listview's data source. What is the correct way to do this? I have > tried a number of ways, and have searched for answers but have found > no working solution yet. You can use MyClass.didDoubleClick_ (e.g. a reference to an unbound method, although bound methods also work). Another option is the method name as a string ("didDoubleClick_"). You can use 'setTarget_(obj)' to set where the message should be send to. Note that the names of action methods should end with an underscore. Ronald |