mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 04:01:56 +02:00
fix textbox key repeat issue, fix numpad issue (in two ways)
This commit is contained in:
@@ -445,7 +445,14 @@ void EventProcess(SDL_Event event)
|
|||||||
{
|
{
|
||||||
if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
|
if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
|
||||||
if (!(event.key.keysym.mod&KEY_MOD_NUM))
|
if (!(event.key.keysym.mod&KEY_MOD_NUM))
|
||||||
event.key.keysym.sym = MapNumpad(event.key.keysym.sym);
|
{
|
||||||
|
SDLKey newKey = MapNumpad(event.key.keysym.sym);
|
||||||
|
if (newKey != event.key.keysym.sym)
|
||||||
|
{
|
||||||
|
event.key.keysym.sym = newKey;
|
||||||
|
event.key.keysym.unicode = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
|
@@ -301,10 +301,13 @@ void Textbox::Tick(float dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Textbox::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
void Textbox::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||||
|
{
|
||||||
|
if (keyDown == key)
|
||||||
{
|
{
|
||||||
keyDown = 0;
|
keyDown = 0;
|
||||||
characterDown = 0;
|
characterDown = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||||
{
|
{
|
||||||
@@ -408,7 +411,7 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
}
|
}
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
if(CharacterValid(character) && !ReadOnly)
|
if(CharacterValid(character) && !ReadOnly)
|
||||||
{
|
{
|
||||||
if(HasSelection())
|
if(HasSelection())
|
||||||
@@ -439,6 +442,8 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
changed = true;
|
changed = true;
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(std::out_of_range &e)
|
catch(std::out_of_range &e)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user