1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Simplified text input handling, fixes hotkeys on windows with text input

This commit is contained in:
Ivan Savenko
2023-07-04 18:42:52 +03:00
parent 81b9aec527
commit 900b1c1763
8 changed files with 58 additions and 41 deletions

View File

@@ -12,6 +12,7 @@
#include "CGuiHandler.h"
#include "WindowHandler.h"
#include "EventDispatcher.h"
#include "Shortcut.h"
#include "../render/Canvas.h"
#include "../windows/CMessage.h"
@@ -22,7 +23,6 @@ CIntObject::CIntObject(int used_, Point pos_):
parent(parent_m),
redrawParent(false),
inputEnabled(true),
captureAllKeys(false),
used(used_),
recActions(GH.defActionsDef),
defActions(GH.defActionsDef),
@@ -37,6 +37,8 @@ CIntObject::~CIntObject()
if(isActive())
deactivate();
GH.events().assertElementInactive(this);
while(!children.empty())
{
if((defActions & DISPOSE) && (children.front()->recActions & DISPOSE))
@@ -148,15 +150,15 @@ void CIntObject::setInputEnabled(bool on)
inputEnabled = on;
if (!isActive())
return;
if (isActive())
{
assert((used & GENERAL) == 0);
assert((used & GENERAL) == 0);
if (on)
activateEvents(used);
else
deactivateEvents(used);
if (on)
activateEvents(used);
else
deactivateEvents(used);
}
for(auto & elem : children)
elem->setInputEnabled(on);
@@ -207,6 +209,9 @@ void CIntObject::addChild(CIntObject * child, bool adjustPosition)
if(adjustPosition)
child->moveBy(pos.topLeft(), adjustPosition);
if (inputEnabled != child->inputEnabled)
child->setInputEnabled(inputEnabled);
if (!isActive() && child->isActive())
child->deactivate();
if (isActive()&& !child->isActive())
@@ -292,7 +297,7 @@ const Rect & CIntObject::center(const Point & p, bool propagate)
bool CIntObject::captureThisKey(EShortcut key)
{
return captureAllKeys;
return false;
}
CKeyShortcut::CKeyShortcut()