Skip to content

Commit

Permalink
FIX: check event to change label to perform markers interactions (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmatsuda authored Sep 9, 2024
1 parent aca7bdd commit 9ceaaa3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions invesalius/gui/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def __init__(self, prnt):
# self.SetSize(wx.Size(1024, 748))

self._show_navigator_message = True
self.edit_data_notebook_label = False

# to control check and unckeck of menu view -> interpolated_slices
main_menu = MenuBar(self)
Expand Down Expand Up @@ -178,19 +179,29 @@ def __bind_events_wx(self):
# Bind global key events.
self.Bind(wx.EVT_CHAR_HOOK, self.OnGlobalKey)

# Bind label edit events.
self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnEditLabel)
self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEditLabel)

def OnEditLabel(self, evt):
if evt.GetEventType() == wx.wxEVT_LIST_BEGIN_LABEL_EDIT:
self.edit_data_notebook_label = True
if evt.GetEventType() == wx.wxEVT_LIST_END_LABEL_EDIT or evt.IsEditCancelled():
self.edit_data_notebook_label = False

def OnGlobalKey(self, event):
"""
Handle all key events at a global level.
"""
keycode = event.GetKeyCode()

# If the key is a move marker key, publish a message to move the marker.
if keycode in const.MOVEMENT_KEYCODES:
if keycode in const.MOVEMENT_KEYCODES and not self.edit_data_notebook_label:
Publisher.sendMessage("Move marker by keyboard", keycode=keycode)
return

# Similarly with 'Del' key; publish a message to delete selected markers.
if keycode == wx.WXK_DELETE:
if keycode == wx.WXK_DELETE and not self.edit_data_notebook_label:
Publisher.sendMessage("Delete selected markers")
return

Expand Down

0 comments on commit 9ceaaa3

Please sign in to comment.