mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Extend code that detects whether a key was consumed by the GUI (Fixes #4016)
This commit is contained in:
parent
2c4b0cc408
commit
9ed1b16553
2 changed files with 29 additions and 5 deletions
|
@ -2000,7 +2000,30 @@ namespace MWGui
|
||||||
bool WindowManager::injectKeyPress(MyGUI::KeyCode key, unsigned int text)
|
bool WindowManager::injectKeyPress(MyGUI::KeyCode key, unsigned int text)
|
||||||
{
|
{
|
||||||
if (!mKeyboardNavigation->injectKeyPress(key, text))
|
if (!mKeyboardNavigation->injectKeyPress(key, text))
|
||||||
return MyGUI::InputManager::getInstance().injectKeyPress(key, text);
|
{
|
||||||
|
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
||||||
|
bool widgetActive = MyGUI::InputManager::getInstance().injectKeyPress(key, text);
|
||||||
|
if (!widgetActive || !focus)
|
||||||
|
return false;
|
||||||
|
// FIXME: MyGUI doesn't allow widgets to state if a given key was actually used, so make a guess
|
||||||
|
if (focus->getTypeName().find("Button") != std::string::npos)
|
||||||
|
{
|
||||||
|
switch (key.getValue())
|
||||||
|
{
|
||||||
|
case MyGUI::KeyCode::ArrowDown:
|
||||||
|
case MyGUI::KeyCode::ArrowUp:
|
||||||
|
case MyGUI::KeyCode::ArrowLeft:
|
||||||
|
case MyGUI::KeyCode::ArrowRight:
|
||||||
|
case MyGUI::KeyCode::Return:
|
||||||
|
case MyGUI::KeyCode::NumpadEnter:
|
||||||
|
case MyGUI::KeyCode::Space:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -674,10 +674,11 @@ namespace MWInput
|
||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
if (kc != OIS::KC_UNASSIGNED)
|
if (kc != OIS::KC_UNASSIGNED)
|
||||||
{
|
{
|
||||||
consumed = SDL_IsTextInputActive() &&
|
consumed = MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Enum(kc), 0);
|
||||||
( !(SDLK_SCANCODE_MASK & arg.keysym.sym) && std::isprint(arg.keysym.sym)); // Little trick to check if key is printable
|
if (SDL_IsTextInputActive() && // Little trick to check if key is printable
|
||||||
bool guiFocus = MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Enum(kc), 0);
|
( !(SDLK_SCANCODE_MASK & arg.keysym.sym) && std::isprint(arg.keysym.sym)))
|
||||||
setPlayerControlsEnabled(!guiFocus);
|
consumed = true;
|
||||||
|
setPlayerControlsEnabled(!consumed);
|
||||||
}
|
}
|
||||||
if (arg.repeat)
|
if (arg.repeat)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue