1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-29 18:32:36 +00:00

Disable repeating for ENTER key in GUI

This commit is contained in:
Andrei Kortunov 2018-09-10 12:55:00 +04:00
parent 33a66b778f
commit 269ef7a559
11 changed files with 31 additions and 2 deletions

View File

@ -351,6 +351,7 @@ namespace MWBase
virtual const MWGui::TextColours& getTextColours() = 0;
virtual bool injectKeyPress(MyGUI::KeyCode key, unsigned int text, bool repeat) = 0;
virtual bool injectKeyRelease(MyGUI::KeyCode key) = 0;
};
}

View File

@ -65,6 +65,9 @@ namespace MWGui
void AlchemyWindow::onAccept(MyGUI::EditBox* sender)
{
onCreateButtonClicked(sender);
// To do not spam onAccept() again and again
MWBase::Environment::get().getWindowManager()->injectKeyRelease(MyGUI::KeyCode::None);
}
void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender)

View File

@ -73,8 +73,10 @@ namespace MWGui
void CountDialog::onEnterKeyPressed(MyGUI::EditBox* _sender)
{
eventOkClicked(NULL, mSlider->getScrollPosition()+1);
setVisible(false);
// To do not spam onEnterKeyPressed() again and again
MWBase::Environment::get().getWindowManager()->injectKeyRelease(MyGUI::KeyCode::None);
}
void CountDialog::onEditValueChanged(int value)

View File

@ -288,6 +288,9 @@ namespace MWGui
void EnchantingDialog::onAccept(MyGUI::EditBox *sender)
{
onBuyButtonClicked(sender);
// To do not spam onAccept() again and again
MWBase::Environment::get().getWindowManager()->injectKeyRelease(MyGUI::KeyCode::None);
}
void EnchantingDialog::onBuyButtonClicked(MyGUI::Widget* sender)

View File

@ -193,8 +193,10 @@ bool KeyboardNavigation::injectKeyPress(MyGUI::KeyCode key, unsigned int text, b
case MyGUI::KeyCode::NumpadEnter:
case MyGUI::KeyCode::Space:
{
// We should disable repeating for activation keys
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::None);
if (repeat)
return false;
return true;
return accept();
}

View File

@ -127,6 +127,9 @@ namespace MWGui
void SaveGameDialog::onEditSelectAccept(MyGUI::EditBox *sender)
{
accept();
// To do not spam onEditSelectAccept() again and again
MWBase::Environment::get().getWindowManager()->injectKeyRelease(MyGUI::KeyCode::None);
}
void SaveGameDialog::onOpen()

View File

@ -420,6 +420,9 @@ namespace MWGui
void SpellCreationDialog::onAccept(MyGUI::EditBox *sender)
{
onBuyButtonClicked(sender);
// To do not spam onAccept() again and again
MWBase::Environment::get().getWindowManager()->injectKeyRelease(MyGUI::KeyCode::None);
}
void SpellCreationDialog::onOpen()

View File

@ -65,6 +65,9 @@ namespace MWGui
void TextInputDialog::onTextAccepted(MyGUI::Edit* _sender)
{
onOkClicked(_sender);
// To do not spam onTextAccepted() again and again
MWBase::Environment::get().getWindowManager()->injectKeyRelease(MyGUI::KeyCode::None);
}
std::string TextInputDialog::getTextInput() const

View File

@ -367,6 +367,9 @@ namespace MWGui
void TradeWindow::onAccept(MyGUI::EditBox *sender)
{
onOfferButtonClicked(sender);
// To do not spam onAccept() again and again
MWBase::Environment::get().getWindowManager()->injectKeyRelease(MyGUI::KeyCode::None);
}
void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender)

View File

@ -2091,6 +2091,11 @@ namespace MWGui
return true;
}
bool WindowManager::injectKeyRelease(MyGUI::KeyCode key)
{
return MyGUI::InputManager::getInstance().injectKeyRelease(key);
}
void WindowManager::GuiModeState::update(bool visible)
{
for (unsigned int i=0; i<mWindows.size(); ++i)

View File

@ -380,6 +380,7 @@ namespace MWGui
virtual const MWGui::TextColours& getTextColours();
virtual bool injectKeyPress(MyGUI::KeyCode key, unsigned int text, bool repeat=false);
virtual bool injectKeyRelease(MyGUI::KeyCode key);
private:
const MWWorld::ESMStore* mStore;