Pass repeat key events to the GUI

For example, one can scroll to the last element in a list by holding down the 'Down Arrow' key.
pull/303/head
scrawl 7 years ago
parent b22fedf4ae
commit e7ad012977

@ -679,6 +679,9 @@ namespace MWInput
bool guiFocus = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0); bool guiFocus = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0);
setPlayerControlsEnabled(!guiFocus); setPlayerControlsEnabled(!guiFocus);
} }
if (arg.repeat)
return;
if (!mControlsDisabled && !consumed) if (!mControlsDisabled && !consumed)
mInputBinder->keyPressed (arg); mInputBinder->keyPressed (arg);
mJoystickLastUsed = false; mJoystickLastUsed = false;

@ -85,14 +85,11 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> v
mMouseListener->mouseReleased(evt.button, evt.button.button); mMouseListener->mouseReleased(evt.button, evt.button.button);
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
if (!evt.key.repeat) mKeyboardListener->keyPressed(evt.key);
{
mKeyboardListener->keyPressed(evt.key);
if (!isModifierHeld(KMOD_ALT) && evt.key.keysym.sym >= SDLK_F1 && evt.key.keysym.sym <= SDLK_F12) if (!isModifierHeld(KMOD_ALT) && evt.key.keysym.sym >= SDLK_F1 && evt.key.keysym.sym <= SDLK_F12)
{ {
mViewer->getEventQueue()->keyPress(osgGA::GUIEventAdapter::KEY_F1 + (evt.key.keysym.sym - SDLK_F1)); mViewer->getEventQueue()->keyPress(osgGA::GUIEventAdapter::KEY_F1 + (evt.key.keysym.sym - SDLK_F1));
}
} }
break; break;

Loading…
Cancel
Save