Lack of keyboard input in a windowed Mac OS X application

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
msxfan
Posts: 4
Joined: Wed Dec 16, 2009 10:12 pm

Lack of keyboard input in a windowed Mac OS X application

Post by msxfan »

Hi! I am using Irrlicht in Mac OSX 10.6 with XCode 3.2.1 and while the engine is great I have found that Mac OSX support is still far from perfect...

My biggest struggle with Irrlicht 1.6 in Mac is that it does not catch the keyboard input when the application runs in a window (it certainly works when the application runs in fullscreen, see createDevice() or createDeviceEx()). However, running in fullscreen is not the solution because sometimes (e.g, when the program crashes) the Irrlicht engine does not restore the Mac desktop (leaving the screen with a frozen rendering instead) and you must reboot the machine. There are other issues with the Irrlicht gui as well but this is probably left aside for a future post. In addition, the Irrlicht window does not appear on top of the other windows (which is quite annoying specially when you add a FPS camera animator node).

Regarding the keyboard problem, I have been diving into the CIrrDeviceMacOSX and my guess is there there is a problem with the routing of keyboard events (keyboard input is routed from the NSApp down to the NSWindow down to the Irrlicht event callbacks). In my desperation, I have been thinking in writting a Mac-specific modification of the Irrlicht engine but my current "solutions" will not preserve compatiblity with the other devices (i.e., Windows or Linux).

It would be great if we can make Irrlicht more compatible with OSX, any ideas/future plans to fix the keyboard problem and the other things?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I'm sorry, but this works for me. I've just checked the example 05 (UserInterface) and it was no problem to type into the editbox. So what's the real problem here?
msxfan
Posts: 4
Joined: Wed Dec 16, 2009 10:12 pm

Post by msxfan »

Well, my 'real' problem is that I cannot type in the edit box as you did with my Irrlicht 1.6 when the application is _not_ run in fullscreen...
msxfan
Posts: 4
Joined: Wed Dec 16, 2009 10:12 pm

Post by msxfan »

Ok, thank you. I have fixed my stupid problem that has bothered me for the last week. Actually, I have modified the Irrlicht engine to work with the wiimote and at first I thought that maybe I have introduced some bugs inadvertently. The real problem was with the x-code project configuration, the key input is not redirected to the Irrlicht event callbacks in a command-line application, you must pick the cocoa application instead and everything works just fine.
fabietto
Posts: 93
Joined: Wed Sep 24, 2008 4:38 pm
Location: Plymouth, UK
Contact:

Post by fabietto »

msxfan wrote:Ok, thank you. I have fixed my stupid problem that has bothered me for the last week. Actually, I have modified the Irrlicht engine to work with the wiimote and at first I thought that maybe I have introduced some bugs inadvertently. The real problem was with the x-code project configuration, the key input is not redirected to the Irrlicht event callbacks in a command-line application, you must pick the cocoa application instead and everything works just fine.
Err... could you please explain this procedure a little bit more in details? I'm experiencing the same issue as you with editboxes... have you created a new Cocoa project rather than a standard command line one?
MrLoom
Posts: 1
Joined: Tue May 31, 2011 12:50 pm

Post by MrLoom »

Seems like I have to struggle with exactly the same problem.

I'm running irrlicht 1.7.2 on Mac OS X 10.6.7 with XCode4. And therefore GCC 4.2/LLVM. At the moment I'm able to build irrlicht and the application based on irrlicht. We're using cmake/make for our build automation. The hint from msxfan to use the Cocoa App template in XCode is not the best solution for me.

So does anybody know how to fix the problem within the make environment?
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Re: Lack of keyboard input in a windowed Mac OS X applicatio

Post by xDan »

I'm not certain if this is the exact same problem, but for me, when using CMake and make rather than XCode, the solution to get input working was to package the binary as a .app

See here:
http://jesper.sarnesjo.org/blog/cocoa-s ... e-builder/

So ensure your binary named APPNAME is in a directory structure like:
APPNAME.app/Contents/MacOS/APPNAME

and then run it by clicking on the APPNAME.app folder.

I guess then it is considered a proper "app" according to the Mac OS and gets given input. Plus you get an icon in the Dock too.
StinkyCat
Posts: 7
Joined: Thu Jun 28, 2012 12:03 pm

Re: Lack of keyboard input in a windowed Mac OS X applicatio

Post by StinkyCat »

msxfan could you please explain how u actually did that? because i see no configuration about this issue in my project... :S
StinkyCat
Posts: 7
Joined: Thu Jun 28, 2012 12:03 pm

Re: Lack of keyboard input in a windowed Mac OS X applicatio

Post by StinkyCat »

ok i think i now understand your solution: instead of creating a command-line application, one has to create a cocoa application.
Post Reply