[Pyobjc-dev] how to add methods to this class in this case?
Brought to you by:
ronaldoussoren
From: Burak N. <bu...@ne...> - 2013-11-09 19:44:58
|
(Sorry for the double post, my mail client glitched—this is the full one.) Hi there, I am building a Qt application called Aether (www.getaether.net). For its Mac version, I have run into the problem of Qt not being able to detect and raise events to Mac’s dock icon clicks. This is an essential and widely used feature on OS X that is completely ignored by Qt, and I want to provide my users this functionality. I have found a way to do this on C++ here: http://aksenkin.blogspot.com/2012/02/how-to-handle-click-on-app-icon-in-mac.html I am using Python, so I need to accomplish it using PyObjC. I have written the following piece of code so far: @objc.signature('B@:') def applicationShouldHandleReopen_hasVisibleWindows_(self, sender): print('hello!') app.onClickOnDock() return True cls = objc.lookUpClass('NSApplication') appInstance = cls.sharedApplication # I'm doing some real crazy runtime shit there. #print(cls, appInstance) delegate = appInstance.definingClass.delegate delClass = delegate.definingClass objc.classAddMethods(cls, [applicationShouldHandleReopen_hasVisibleWindows_]) But this has no effect. No method gets triggered, nothing happens. I have little to no C++ knowledge, so I am probably missing a nuance in the translation. Can anyone point me in the right direction? Regards, Burak |