summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/samplesorter.cc11
-rw-r--r--src/samplesorter.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/src/samplesorter.cc b/src/samplesorter.cc
index 91bc6b4..29c24e6 100644
--- a/src/samplesorter.cc
+++ b/src/samplesorter.cc
@@ -28,6 +28,7 @@
#include <QPainter>
#include <QPaintEvent>
+#include <QKeyEvent>
#include <stdio.h>
@@ -42,7 +43,7 @@ SampleSorter::SampleSorter(Selections& s, Selections& p, Instrument& instrument)
, instrument(instrument)
{
setMouseTracking(true);
-
+ setFocusPolicy(Qt::ClickFocus); // Enable keyboard event on click
data = NULL;
size = 0;
attlen = 666; // Magical constants needs biblical proportions...
@@ -329,3 +330,11 @@ void SampleSorter::mouseReleaseEvent(QMouseEvent* event)
}
}
}
+
+void SampleSorter::keyReleaseEvent(QKeyEvent* event)
+{
+ if(selections.active() != SEL_NONE && event->key() == Qt::Key_Delete)
+ {
+ selections.remove(selections.active());
+ }
+}
diff --git a/src/samplesorter.h b/src/samplesorter.h
index 496274d..056161d 100644
--- a/src/samplesorter.h
+++ b/src/samplesorter.h
@@ -59,6 +59,7 @@ protected:
void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
+ void keyReleaseEvent(QKeyEvent* event) override;
private:
sel_id_t getSelectionByCoordinate(int x, int y);