Skip to content

Commit

Permalink
Add right-click to deselect label
Browse files Browse the repository at this point in the history
  • Loading branch information
jluethi committed Jul 19, 2024
1 parent fa22d2b commit 0950ccf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/napari_feature_classifier/annotator_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,16 @@ def toggle_label(self, labels_layer, event):
napari_info("No label clicked.")
return

labels_layer.features.loc[
labels_layer.features[self._label_column] == label, "annotations"
] = self._class_selector.value.value
# Left click: add annotation
if event.button == 1:
labels_layer.features.loc[
labels_layer.features[self._label_column] == label, "annotations"
] = self._class_selector.value.value
# Right click: Remove annotation
elif event.button == 2:
labels_layer.features.loc[
labels_layer.features[self._label_column] == label, "annotations"
] = 0.0

# Update only the single color value that changed
self.update_single_color(labels_layer, label)
Expand Down

0 comments on commit 0950ccf

Please sign in to comment.