summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-11-29 11:05:58 +0330
committerAndreas Kling <kling@serenityos.org>2020-11-30 12:07:45 +0100
commitc84756efa8266715798d41353b733fb41c6ead89 (patch)
tree7232b0c5a29c1da617509c6b57df47e14bd2c045 /Libraries/LibGUI
parent474453244b591ff8c90547831e798d66c5d2be1e (diff)
downloadserenity-c84756efa8266715798d41353b733fb41c6ead89.zip
LibGUI: Don't start editing with (just) modifier keys when AnyKeyPressed
This fixes the control key starting an edit on (and inserting a nul character into) a cell in Spreadsheet.
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r--Libraries/LibGUI/TableView.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Libraries/LibGUI/TableView.cpp b/Libraries/LibGUI/TableView.cpp
index f65ace1925..8b143df504 100644
--- a/Libraries/LibGUI/TableView.cpp
+++ b/Libraries/LibGUI/TableView.cpp
@@ -177,11 +177,12 @@ void TableView::keydown_event(KeyEvent& event)
if (event.is_accepted())
return;
- if (is_editable() && edit_triggers() & EditTrigger::AnyKeyPressed && !event.text().is_empty()) {
+ auto is_delete = event.key() == Key_Delete || event.key() == Key_Backspace;
+ if (is_editable() && edit_triggers() & EditTrigger::AnyKeyPressed && (event.code_point() != 0 || is_delete)) {
begin_editing(cursor_index());
if (m_editing_delegate) {
- if (event.key() == KeyCode::Key_Delete || event.key() == KeyCode::Key_Backspace)
- m_editing_delegate->set_value(String::empty());
+ if (is_delete)
+ m_editing_delegate->set_value(event.key() == Key_Delete ? String {} : String::empty());
else
m_editing_delegate->set_value(event.text());
}