SDL and Apple Shortcuts
Does anyone know how to hide(Cmd-H) an SDL program? And is there a way to do this without using Objective-C? Can I add some code to SDLMain.m that will do this for me.
Thanks,
Mark
Thanks,
Mark
if you add to SDLMain.m
and then when you detect a command-H,
that should work without requiring ObjC to appear in your own code.
Code:
void HideMySDLApp(void)
{
[NSApp hide:nil];
}
and then when you detect a command-H,
Code:
extern void HideMySDLApp(void);
HideMySDLApp();
that should work without requiring ObjC to appear in your own code.
Thanks for helping me out with this one, but I get an error with the code.
Undefined symbols for architecture x86_64:
"HideMySDLApp()"
It is an Apple Mach-O Linker (id) Error with HideMySDLApp()
Undefined symbols for architecture x86_64:
"HideMySDLApp()"
It is an Apple Mach-O Linker (id) Error with HideMySDLApp()
If you're writing C++ you need to redeclare it
Code:
extern "C" HideMySDLApp();
A little confused. Where do I put this line of code? I tried replacing the previous line of code that had extern in it and that did not work.
Ok, I figured it out. extern "C" void HideMySDLApp(void); must be outside of the function.
Thanks OneSadCookie.
Thanks OneSadCookie.
That's not a great solution and it doesn't fix command-Q, command-W, command-M, etc.
I found this solution on a mailing list a while ago, which is what I've been using:
In "@implementation SDLApplication", add the method:
And in the applicationDidFinishLaunching: method in SDLMain's implementation, add a function call setenv("SDL_ENABLEAPPEVENTS", "1", 1) before SDL_main(...) function is called.
I found this solution on a mailing list a while ago, which is what I've been using:
In "@implementation SDLApplication", add the method:
Code:
- (void)sendEvent:(NSEvent *)anEvent
{
if (NSKeyDown == [anEvent type] || NSKeyUp == [anEvent type])
{
if ([anEvent modifierFlags] & NSCommandKeyMask)
[super sendEvent:anEvent];
}
else
{
[super sendEvent:anEvent];
}
}
And in the applicationDidFinishLaunching: method in SDLMain's implementation, add a function call setenv("SDL_ENABLEAPPEVENTS", "1", 1) before SDL_main(...) function is called.