I am compiling the cinder samples on macos using a simple Makefile and it turns out that no keyboard key events are passed through to the app (opengl rendering context). The Makefile is super simple. Mouse inputs work with cameraUI, but not keys. Also, the Params input isn’t working properly when launched from the command line. It is like Terminal is getting the keyboard input and I can’t figure out how to get the cinder app to receive the inputs.
One other thing which ]may not be relevant is that when running glut samples (for example) from the command line a new dock icon is added for the running app and keys/mouse work. When running the command line cinder binary I don’t get an icon added to the dock.
Wondering if anyone knows what dumb thing I have done/missed? Thanks!
Sorry, I don’t really know the answer for your questions. But I have always built cinder from the command line. Used scons for years, but recently I moved to Cinder’s new CMake system. It can save you a lot of headaches in my opinion.
Cocoa is weird about events unless you create a properly formed application bundle. You could probably grab a template one and copy your executable into
Contents/MacOS as part of your build step. You may even be able to compile as objective-c++ and do some bad ju-ju with the
CinderViewMac returned by
getWindow()->getNative(), but really your best bet is to generate a properly formed project up front with tinderbox or cmake and save yourself the trouble. You can then build the resultant project with
xcodebuild in your makefile if you want to keep the same (rough) workflow.
Thanks - I figured it was something I was missing from the build environment. The makefile I wrotewas really basic and works for everything except keys. Will look into cmake.
I will investigate further - thanks for the great suggestions! Definitely some things I can learn more about. I will post back if I make any progress.
Hi. I know this is an old topic but came across the same problem in current 0.9.2dev.
Due to my preference of working in CLion rather than XCode, I was facing the same problem. In this example https://github.com/gamedevtech/CocoaOpenGLWindow I saw the keyboard loop working fine, so without the required Cocoa knowledge just tried to figure out what was the difference. I can confirm that I got the keyboard handling working correctly after adding the line below into AppImplMac.mm init():
// Since Snow Leopard, programs without application bundles and Info.plist files don't get a menubar
// and can't be brought to the front unless the presentation option is changed
I’m not familiar enough with Cinder or Cocoa for that matter to do any git proposals, but if someone in the know this is the right thing to commit, please do.
Another nuisance was that without the application bundle the focus stays back on the terminal as per https://stackoverflow.com/questions/5032203/can-a-cocoa-apps-executable-steal-focus-from-caller .
I used the proposed solution and added a second line to the snippet above:
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
and can confirm that Cocoa window now comes up. Again, if someone could confirm this would be a right thing to do, would be nice to have it in original distribution.
I have created a new issue for this. I’m not familiar enough with this myself, but I’m sure someone will look into it.
Upon a bit more reading, I believe there is a more elegant solution, that I’m trying myself and will update here. Using cmake’s resource function and a few more steps outlined here and here I think it is possible to create a full mac bundle with only cmake and without using xcode, which was something I wasn’t aware.
If that is the case, no need to force it in the code anyway…
So, after reading a bit more about Cocoa, I don’t think my code change is required or even appropriate. The comment seems to be correct, i.e. an application outside a bundle doesn’t have a “proper UI” without that setting, but the proper solution, even for someone that wants to stay away of XCode, doesn’t require the change of cinder source.
It will be enough to build the bundle which is totally supported with CMake target properties. Something like this is enough:
This alone will create the sample.app application, which then will not create any terminal application and will handle keyboard correctly. Related with that you can find all the sort of examples to also set icons, entitlements, custom plist, etc…
Sorry for the confusion.
Not sure if you have checked this out already but Cinder already comes with support for CMake. You can find a guide here. As reported by some people this should also work directly and without issues with CLion.
ci_make_app macro is a convenient helper that can be used for building an application bundle either through Makefiles or Xcode generated projects which should take care of the issues you describe here. Check the guide or the samples under
SampleFolder/proj/cmake for example usage.