HackStudio: Don't track ctrl key state manually

Since we only need it in the mouse and key event handlers, we can get
the ctrl key state from the event. :^)
This commit is contained in:
Andreas Kling 2020-10-29 15:31:58 +01:00
parent 77e9eadd9d
commit c3a79e1483
2 changed files with 2 additions and 14 deletions

View file

@ -222,7 +222,7 @@ void Editor::mousemove_event(GUI::MouseEvent& event)
if (hovering_lines_ruler && !is_in_drag_select())
set_override_cursor(Gfx::StandardCursor::Arrow);
else if (m_hovering_editor)
set_override_cursor(m_hovering_link && m_holding_ctrl ? Gfx::StandardCursor::Hand : Gfx::StandardCursor::IBeam);
set_override_cursor(m_hovering_link && event.ctrl() ? Gfx::StandardCursor::Hand : Gfx::StandardCursor::IBeam);
for (auto& span : document().spans()) {
if (span.range.contains(m_previous_text_position) && !span.range.contains(text_position)) {
@ -349,10 +349,7 @@ void Editor::keydown_event(GUI::KeyEvent& event)
}
};
if (event.key() == Key_Control)
m_holding_ctrl = true;
if (m_holding_ctrl && event.key() == Key_Space) {
if (event.ctrl() && event.key() == Key_Space) {
autocomplete_action();
}
GUI::TextEditor::keydown_event(event);
@ -362,13 +359,6 @@ void Editor::keydown_event(GUI::KeyEvent& event)
}
}
void Editor::keyup_event(GUI::KeyEvent& event)
{
if (event.key() == Key_Control)
m_holding_ctrl = false;
GUI::TextEditor::keyup_event(event);
}
void Editor::enter_event(Core::Event& event)
{
m_hovering_editor = true;

View file

@ -73,7 +73,6 @@ private:
virtual void mousemove_event(GUI::MouseEvent&) override;
virtual void mousedown_event(GUI::MouseEvent&) override;
virtual void keydown_event(GUI::KeyEvent&) override;
virtual void keyup_event(GUI::KeyEvent&) override;
virtual void enter_event(Core::Event&) override;
virtual void leave_event(Core::Event&) override;
@ -105,7 +104,6 @@ private:
GUI::TextPosition m_previous_text_position { 0, 0 };
bool m_hovering_editor { false };
bool m_hovering_link { false };
bool m_holding_ctrl { false };
bool m_autocomplete_in_focus { false };
OwnPtr<LanguageClient> m_language_client;