Skip to content

Commit

Permalink
Merge branch 'invesalius:master' into fix-linting
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-abdelgawad authored Sep 12, 2024
2 parents 675589a + 9ceaaa3 commit a4f9685
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 @@ -114,6 +114,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 @@ -176,19 +177,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 a4f9685

Please sign in to comment.