fix textbox key repeat issue, fix numpad issue (in two ways)

This commit is contained in:
jacob1 2014-03-11 12:53:42 -04:00
parent 3f65b47a5e
commit 7ce9907f82
2 changed files with 44 additions and 32 deletions

View File

@ -443,9 +443,16 @@ float currentWidth, currentHeight;
void EventProcess(SDL_Event event)
{
if(event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
if(!(event.key.keysym.mod&KEY_MOD_NUM))
event.key.keysym.sym = MapNumpad(event.key.keysym.sym);
if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
if (!(event.key.keysym.mod&KEY_MOD_NUM))
{
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)
{
case SDL_QUIT:
@ -462,7 +469,7 @@ void EventProcess(SDL_Event event)
engine->onMouseMove(event.motion.x*inputScale, event.motion.y*inputScale);
break;
case SDL_MOUSEBUTTONDOWN:
if(event.button.button == SDL_BUTTON_WHEELUP)
if (event.button.button == SDL_BUTTON_WHEELUP)
{
engine->onMouseWheel(event.motion.x*inputScale, event.motion.y*inputScale, 1);
}
@ -476,7 +483,7 @@ void EventProcess(SDL_Event event)
}
break;
case SDL_MOUSEBUTTONUP:
if(event.button.button != SDL_BUTTON_WHEELUP && event.button.button != SDL_BUTTON_WHEELDOWN)
if (event.button.button != SDL_BUTTON_WHEELUP && event.button.button != SDL_BUTTON_WHEELDOWN)
engine->onMouseUnclick(event.motion.x*inputScale, event.motion.y*inputScale, event.button.button);
break;
#ifdef OGLI

View File

@ -302,8 +302,11 @@ void Textbox::Tick(float dt)
void Textbox::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
if (keyDown == key)
{
keyDown = 0;
characterDown = 0;
}
}
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();
break;
}
default:
if(CharacterValid(character) && !ReadOnly)
{
if(HasSelection())
@ -439,6 +442,8 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
changed = true;
ClearSelection();
}
break;
}
}
catch(std::out_of_range &e)
{