1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Removed usage of SDL_KeyboardEvent from UI code

This commit is contained in:
Ivan Savenko
2023-02-02 18:02:25 +02:00
parent 860fe43131
commit d4fba3787c
26 changed files with 160 additions and 131 deletions

View File

@@ -16,7 +16,6 @@
#include <SDL_pixels.h>
#include <SDL_surface.h>
#include <SDL_events.h>
IShowActivatable::IShowActivatable()
{
@@ -325,7 +324,7 @@ const Rect & CIntObject::center(const Point & p, bool propagate)
return pos;
}
bool CIntObject::captureThisEvent(const SDL_KeyboardEvent & key)
bool CIntObject::captureThisKey(const SDL_Keycode & key)
{
return captureAllKeys;
}
@@ -343,14 +342,26 @@ CKeyShortcut::CKeyShortcut(std::set<int> Keys)
:assignedKeys(Keys)
{}
void CKeyShortcut::keyPressed(const SDL_KeyboardEvent & key)
void CKeyShortcut::keyDown(const SDL_Keycode & key)
{
if(vstd::contains(assignedKeys,key.keysym.sym)
|| vstd::contains(assignedKeys, CGuiHandler::numToDigit(key.keysym.sym)))
if(vstd::contains(assignedKeys,key)
|| vstd::contains(assignedKeys, CGuiHandler::numToDigit(key)))
{
bool prev = mouseState(MouseButton::LEFT);
updateMouseState(MouseButton::LEFT, key.state == SDL_PRESSED);
clickLeft(key.state == SDL_PRESSED, prev);
updateMouseState(MouseButton::LEFT, true);
clickLeft(true, prev);
}
}
void CKeyShortcut::keyReleased(const SDL_Keycode & key)
{
if(vstd::contains(assignedKeys,key)
|| vstd::contains(assignedKeys, CGuiHandler::numToDigit(key)))
{
bool prev = mouseState(MouseButton::LEFT);
updateMouseState(MouseButton::LEFT, false);
clickLeft(false, prev);
}
}