[Pyobjc-dev] Subclassing NSTextField
Brought to you by:
ronaldoussoren
From: Steven D. A. <st...@ne...> - 2002-12-17 19:25:51
|
Hi, I may be having several misconceptions here, but I've looked at several sources without success, so I thought I'd ask. I want to examine the keys that are typed into an NSTextField, so I subclassed NSTextField in IB. In IB, I drew an NSTextField and set its custom class to my new class. Then in Main.py I defined the class as follows: class SearchTextField( AppKit.NSTextField ): #def init( self ): # print "initializing SearchTextField" # return self def keyDown_( self, the_event ): the_keys = the_event.characters() print "Received keys: ", the_keys It was my understanding that this should be sufficient; the new SearchTextField should use the class I defined. But I don't see my diagnostic message when I type. I also tried uncommenting the init function above, also with no effect (i.e. No diagnostic message when the app is starting up). I have it commented out because I assumed the standard init function the class inherits from NSTextField was good enough. On a related note, is there any mechanism to implement categories in pyobjc? I thought this question had been asked before, but I couldn't find it in my archive. steve -- |