From f6ad17012c2322f598f5f51cfb06d8ce2b8a0820 Mon Sep 17 00:00:00 2001 From: Pavel Kulik Date: Thu, 16 Jan 2025 13:25:37 -0800 Subject: [PATCH] Fix key listener behavior --- Source/SpikeSorterCanvas.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/SpikeSorterCanvas.cpp b/Source/SpikeSorterCanvas.cpp index 6929341..62de170 100644 --- a/Source/SpikeSorterCanvas.cpp +++ b/Source/SpikeSorterCanvas.cpp @@ -147,6 +147,8 @@ void SpikeSorterCanvas::setActiveElectrode (Electrode* electrode_) void SpikeSorterCanvas::removeUnitOrBox() { int unitID, boxID; + if (electrode == nullptr) + return; electrode->plot->getSelectedUnitAndBox (unitID, boxID); bool selectNewBoxUnit = false; @@ -245,10 +247,10 @@ bool SpikeSorterCanvas::keyPressed (const KeyPress& key, Component* c) if (key.getKeyCode() == KeyPress::deleteKey || key.getKeyCode() == KeyPress::backspaceKey) { removeUnitOrBox(); - return false; + return true; } - return true; + return false; } void SpikeSorterCanvas::buttonClicked (Button* button)