From Juan Manuel Alvarez, "When handling keyboard events on osgQt, if a key is kept pressed, multiple sequences of KEYDOWN -> KEYUP events are fired.

This is because Qt auto repeats keyboard events, so multiple calls are made to GLWidget::keyPressEvent and GLWidget::keyReleaseEvent by Qt, and subsequently translated to OSG events.

The way to solve this is ignoring key released auto repeated events (see http://qt-project.org/doc/qt-4.8/qkeyevent.html#isAutoRepeat), so multiple KEYDOWN events are fired, but only one KEYUP.

I attach a modified osgQt/GraphicsWindowQt.cpp with this change."
This commit is contained in:
Robert Osfield 2013-06-20 10:05:56 +00:00
parent bab56f9854
commit 7d2f9f3a0d

View File

@ -269,9 +269,16 @@ void GLWidget::keyPressEvent( QKeyEvent* event )
void GLWidget::keyReleaseEvent( QKeyEvent* event )
{
setKeyboardModifiers( event );
int value = s_QtKeyboardMap.remapKey( event );
_gw->getEventQueue()->keyRelease( value );
if( event->isAutoRepeat() )
{
event->ignore();
}
else
{
setKeyboardModifiers( event );
int value = s_QtKeyboardMap.remapKey( event );
_gw->getEventQueue()->keyRelease( value );
}
// this passes the event to the regular Qt key event processing,
// among others, it closes popup windows on ESC and forwards the event to the parent widgets