MacOS: Console App vs. GUI App + dylib

BlitzMax Forums/BlitzMax Programming/MacOS: Console App vs. GUI App + dylib

LordChaos(Posted 2010) [#1]
Hi!

Today I came across a cosmetic problem concerning the two kinds of building bmax applications on the Mac.

I'm writing an application "A" which runs another console application "B" (also written in BMax by me) using PUB.FreeProcess. "B" dynamically loads some libraries which use Cocoa for creating windows etc. .

However, if i

1.) build app "B" as a console app, the windows I create using the dylib do not receive keyboard (probably also other) events. I'd guess that this is an issue with dealing with the wrong NSApp instance in the library, but I'm not sure.

2.) build app "B" as a GUI app, I can't run it in the terminal. If I open it, it just hangs.

Any advice? I'm not sure if this has to do with the way I create the window in the lib or the way BMax builds Mac applications.

Here is an example how I wait for a key stroke in the dylib (works fine when "B" is built as a GUI app, otherwise not):

void Sleep() {
	
	NSEvent *event;
	
	while(1) {
		if(event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES])
			if([event type] == NSKeyDown) break;
		[NSApp sendEvent:event];
	}
	
}