LibGUI: Don't enter TableView edit mode when a control key is pressed

A key press, which is an ASCII control character will no longer cause
TableView to begin editing.

This fixes an issue in Spreadsheet where navigating to a cell then
pressing escape would cause a that cell's text to be set to a
non-printable value. Pressing escape after navigating to a cell
now has no effect.
This commit is contained in:
Tim Ledbetter 2023-09-27 09:42:18 +01:00 committed by Jelle Raaijmakers
parent 4e2e2027c3
commit 361e29cfc9

View file

@ -194,8 +194,8 @@ void TableView::keydown_event(KeyEvent& event)
auto is_delete = event.key() == Key_Delete;
auto is_backspace = event.key() == Key_Backspace;
auto is_clear = is_delete || is_backspace;
auto has_ctrl = event.modifiers() & KeyModifier::Mod_Ctrl;
if (is_editable() && edit_triggers() & EditTrigger::AnyKeyPressed && (event.code_point() != 0 || is_clear) && !has_ctrl) {
auto is_control_character = is_ascii_c0_control(event.code_point());
if (is_editable() && edit_triggers() & EditTrigger::AnyKeyPressed && !event.ctrl() && (!is_control_character || is_clear)) {
begin_editing(cursor_index());
if (m_editing_delegate) {
if (is_delete) {