mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 17:55:09 +00:00
HackStudio: Allow moving the selected widgets using the arrow keys
This is a nice complement to moving widgets with the mouse. :^)
This commit is contained in:
parent
567769eb2f
commit
c8637e0206
7 changed files with 47 additions and 0 deletions
|
@ -81,3 +81,32 @@ void CursorTool::on_mousemove(GMouseEvent& event)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CursorTool::on_keydown(GKeyEvent& event)
|
||||
{
|
||||
dbg() << "CursorTool::on_keydown";
|
||||
|
||||
auto move_selected_widgets_by = [this](int x, int y) {
|
||||
m_editor.selection().for_each([&](auto& widget) {
|
||||
widget.move_by(x, y);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
};
|
||||
|
||||
if (event.modifiers() == 0) {
|
||||
switch (event.key()) {
|
||||
case Key_Down:
|
||||
move_selected_widgets_by(0, m_editor.form_widget().grid_size());
|
||||
break;
|
||||
case Key_Up:
|
||||
move_selected_widgets_by(0, -m_editor.form_widget().grid_size());
|
||||
break;
|
||||
case Key_Left:
|
||||
move_selected_widgets_by(-m_editor.form_widget().grid_size(), 0);
|
||||
break;
|
||||
case Key_Right:
|
||||
move_selected_widgets_by(m_editor.form_widget().grid_size(), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue