How to Use a Method as a completionHandler?

I’m tinkering with some animation stuff, and I’m able to set the duration for an implicit animation of a window’s opacity/transparency using NSAnimationContext. I’d like to execute a Xojo method when the animation completes. There is a completionHandler property of the NSAnimationContext class, but I haven’t figured out how to make use of it within Xojo. It’s defined as an Obj-C Block. How would I set up the declare, and how do I pass a Xojo method? I’ve tried, unsuccessfully, to use a Ptr data type and pass the AddressOf the method.

Has anyone done this kind of thing? Any help would be greatly appreciated.

-Steve

I’ve run into creating an Obj-C Block and I think it can’t be done with declares. A Block is actually a structure of some sort, I found docs on what its parts are and tried manually building it, got the declare to accept the structure as a Block but it never executed the callback. That’s a super shaky route anyways. Maybe there’s a declare that can properly build one (haven’t found it). My current strategy is to make a plugin to wrap the Block.

Thanks for the reply, doofus. In this particular case, I could probably implement some kind of cheese-dog hack using a timer, but it would be nice if there was a more elegant general purpose approach to using Obj-C Blocks within Xojo. If I learn anything more, I’ll post back to this thread.

-Steve

I’d expect any callback to take a handle to the method via AddressOf, see the callbacks used for the fullscreen declares in http://www.jo-tools.ch/realbasic/lioncocoadeclares/

Hope that helps.

If the callback takes a method pointer AddressOf should work
But blocks are not that way

Check out Joe’s post here https://forum.xojo.com/3586-obj-c-blocks-as-callbacks