DemoOpenGLCanvas and keyPressed


#1

I’ve been trying to get keyPressed working with DemoOpenGLCanvas in the juce demo but I have been unsuccessful. As far as I can tell since DemoOpenGLCanvas subclasses Component, it should work, but alas, it does not. Please tell me the error in my ways!

As a base example, I added the following code to OpenGLDemo.cpp, right below the mouse drag method

bool keyPressed (const KeyPress& key) { Logger::outputDebugString(String(key.getTextCharacter())); return true; }

…and it never gets called.


#2

Could just be that you’ve not called setWantsKeyboardFocus() or something to let your comp actually get focused?


#3

DOH! I knew it would be simple, thanks Jules.