Skip to content

Commit

Permalink
Overwrite keybindings of prompt layers (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
constantinpape authored Sep 30, 2024
1 parent 1a555a4 commit bd9f44c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions micro_sam/sam_annotator/_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ def _create_keybindings(self):
def _segment(viewer):
self._widgets["segment"](viewer)

# Note: we also need to over-write the keybindings for specific layers.
# See https://github.com/napari/napari/issues/7302 for details.
# Here, we need to over-write the 's' keybinding for both of the prompt layers.
prompt_layer = self._viewer.layers["prompts"]
point_prompt_layer = self._viewer.layers["point_prompts"]

@prompt_layer.bind_key("s", overwrite=True)
def _segment_prompts(event):
self._widgets["segment"](self._viewer)

@point_prompt_layer.bind_key("s", overwrite=True)
def _segment_point_prompts(event):
self._widgets["segment"](self._viewer)

@self._viewer.bind_key("c", overwrite=True)
def _commit(viewer):
self._widgets["commit"](viewer)
Expand Down

0 comments on commit bd9f44c

Please sign in to comment.