Re: [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 21:34:25
|
…. Thank you. I’m speechless. I have been fighting with this issue since the last 30-ish hours, and have just thrown the towel a few hours ago. Best, Burak On November 9, 2013 at 3:52:48 PM, Robert Klep (rob...@gm...) wrote: Hi Burak, The signature of that specific method is different: applicationShouldHandleReopen:hasVisibleWindows: Sent by the application to the delegate prior to default behavior to reopen (rapp) AppleEvents. - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag (full documentation here) Here's a minimal example that works for me: #!/usr/bin/env python from AppKit import NSObject, NSApplication from Foundation import NSLog import objc class TestApp(NSObject): @objc.signature('B@:#B') def applicationShouldHandleReopen_hasVisibleWindows_(self, app, flag): NSLog('Hello!') return True def applicationDidFinishLaunching_(self, notification): NSLog('App running') if __name__ == '__main__': sharedapp = NSApplication.sharedApplication() testapp = TestApp.alloc().init() sharedapp.setDelegate_(testapp) sharedapp.run() Regards, Robert Burak Nehbit <bu...@ne...> wrote on Sat Nov 09 2013 at 20:45:40: (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 ------------------------------------------------------------------------------ November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk_______________________________________________ Pyobjc-dev mailing list Pyo...@li... https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |