Hold arrow keys to move selected element in UI editor (#4968)

* Hold arrow keys to move selected element in UI editor

Signed-off-by: chiyteng <chiyteng@amazon.com>

* Fix nits

Signed-off-by: chiyteng <chiyteng@amazon.com>

* Hold arrow keys to move selected element in UI editor

Signed-off-by: chiyteng <chiyteng@amazon.com>

* undo enum changes

Signed-off-by: chiyteng <chiyteng@amazon.com>

* remove extra spaces

Signed-off-by: chiyteng <chiyteng@amazon.com>

* fix comments

Signed-off-by: chiyteng <chiyteng@amazon.com>

* refactor key event code

Signed-off-by: chiyteng <chiyteng@amazon.com>
This commit is contained in:
chiyenteng
2021-10-25 15:59:31 -07:00
committed by GitHub
parent 3b4b8c3549
commit 4e6f1981b9
3 changed files with 55 additions and 133 deletions
@@ -739,14 +739,32 @@ void ViewportInteraction::MouseWheelEvent(QWheelEvent* ev)
bool ViewportInteraction::KeyPressEvent(QKeyEvent* ev)
{
if (ev->key() == Qt::Key_Space)
switch (ev->key())
{
case Qt::Key_Space:
if (!ev->isAutoRepeat())
{
ActivateSpaceBar();
}
return true;
case Qt::Key_Up:
Nudge(ViewportInteraction::NudgeDirection::Up,
(ev->modifiers() & Qt::ShiftModifier) ? ViewportInteraction::NudgeSpeed::Fast : ViewportInteraction::NudgeSpeed::Slow);
return true;
case Qt::Key_Down:
Nudge(ViewportInteraction::NudgeDirection::Down,
(ev->modifiers() & Qt::ShiftModifier) ? ViewportInteraction::NudgeSpeed::Fast : ViewportInteraction::NudgeSpeed::Slow);
return true;
case Qt::Key_Left:
Nudge(ViewportInteraction::NudgeDirection::Left,
(ev->modifiers() & Qt::ShiftModifier) ? ViewportInteraction::NudgeSpeed::Fast : ViewportInteraction::NudgeSpeed::Slow);
return true;
case Qt::Key_Right:
Nudge(ViewportInteraction::NudgeDirection::Right,
(ev->modifiers() & Qt::ShiftModifier) ? ViewportInteraction::NudgeSpeed::Fast : ViewportInteraction::NudgeSpeed::Slow);
return true;
default:
break;
}
return false;