Skip to content
Permalink
Browse files

prevent weirdness when ctrl/shift/alt key event is canceled

  • Loading branch information...
jacob1 committed Feb 24, 2019
1 parent 1536736 commit 79aef1dab6fdb090eca74ae28ce0e271c94d1d29
Showing with 13 additions and 28 deletions.
  1. +13 −28 src/gui/game/GameView.cpp
@@ -1646,18 +1646,6 @@ void GameView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl,
{
switch (key)
{
case SDLK_LALT:
case SDLK_RALT:
enableAltBehaviour();
break;
case SDLK_LCTRL:
case SDLK_RCTRL:
enableCtrlBehaviour();
break;
case SDLK_LSHIFT:
case SDLK_RSHIFT:
enableShiftBehaviour();
break;
case SDLK_TAB: //Tab
c->ChangeBrush();
break;
@@ -1691,21 +1679,6 @@ void GameView::OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctr
c->SetZoomEnabled(false);
return;
}
switch(key)
{
case SDLK_LALT:
case SDLK_RALT:
disableAltBehaviour();
break;
case SDLK_LCTRL:
case SDLK_RCTRL:
disableCtrlBehaviour();
break;
case SDLK_LSHIFT:
case SDLK_RSHIFT:
disableShiftBehaviour();
break;
}
}

void GameView::OnBlur()
@@ -1857,13 +1830,25 @@ void GameView::DoTextInput(String text)

void GameView::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (shift && !shiftBehaviour)
enableShiftBehaviour();
if (ctrl && !ctrlBehaviour)
enableCtrlBehaviour();
if (alt && !altBehaviour)
enableAltBehaviour();
if (c->KeyPress(key, scan, repeat, shift, ctrl, alt))
Window::DoKeyPress(key, scan, repeat, shift, ctrl, alt);
}

void GameView::DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if(c->KeyRelease(key, scan, repeat, shift, ctrl, alt))
if (!shift && shiftBehaviour)
disableShiftBehaviour();
if (!ctrl && ctrlBehaviour)
disableCtrlBehaviour();
if (!alt && altBehaviour)
disableAltBehaviour();
if (c->KeyRelease(key, scan, repeat, shift, ctrl, alt))
Window::DoKeyRelease(key, scan, repeat, shift, ctrl, alt);
}

0 comments on commit 79aef1d

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.