Page 1 of 1

Help With conversion

Posted: Tue Feb 05, 2013 10:20 pm
by spacebuddy
Hi All,

I am trying to convert this code to PB.

int getActiveWindowOSX(){
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
NSApplication *myApp;
myApp=[NSApplication sharedApplication];
NSWindow *myWindow = [myApp keyWindow];
[pool release];
// return *NSWindow;
}

This code should give me the foreground window running.

In PB I tried.

Import C""
Define myApp,NSWindow
myApp=CocoaMessage(0,0,"NSApplication sharedApplication")
EndImport


MSWIndow=CocoaMessage(0,myApp, "KeyWindow",0)

MSWindow always comes back with 0, something I did is wrong :(

Re: Help With conversion

Posted: Wed Feb 06, 2013 6:45 am
by wilbert
With PB 5.10

Code: Select all

KeyWindowID = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "keyWindow")
Debug KeyWindowID

Re: Help With conversion

Posted: Wed Feb 06, 2013 7:01 am
by spacebuddy
I was so close, thanks Wilbert :D