Skip to content

Commit

Permalink
Give the focus back to the main Window
Browse files Browse the repository at this point in the history
Otherwise the keyboard shortcuts stop working after using the app
  • Loading branch information
RMPR committed Jan 12, 2021
1 parent 25681d3 commit 8a127fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion atbswp/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@ def load_file(self, event):
self._capture = self.load_content(dlg.GetPath())
with open(TMP_PATH, 'w') as f:
f.write(self._capture)
event.EventObject.Parent.panel.SetFocus()
dlg.Destroy()

def save_file(self, event):
"""Save the capture currently loaded."""
event.EventObject.Parent.panel.SetFocus()

with wx.FileDialog(self.parent, "Save capture file", wildcard="*",
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as fileDialog:

Expand Down Expand Up @@ -287,7 +290,7 @@ def recording_timer(event):
current_value = settings.CONFIG.getint('DEFAULT', 'Recording Timer')
except:
current_value = 0

dialog = SliderDialog(None, title="Choose an amount of time (seconds)", size=(500, 50), default_value=current_value)
dialog.ShowModal()
new_value = dialog.value
Expand Down Expand Up @@ -361,6 +364,7 @@ def play(self, capture, toggle_button):
def action(self, event):
"""Replay a `count` number of time."""
toggle_button = event.GetEventObject()
toggle_button.Parent.panel.SetFocus()
count = settings.CONFIG.getint('DEFAULT', 'Repeat Count')
infinite = settings.CONFIG.getboolean('DEFAULT', 'Infinite Playback')
if toggle_button.Value:
Expand Down Expand Up @@ -416,6 +420,7 @@ def compile(event):
wx.LogError("No capture loaded")
return
default_file = "capture.pyc"
event.EventObject.Parent.panel.SetFocus()
with wx.FileDialog(parent=event.GetEventObject().Parent, message="Save capture executable",
defaultDir=os.path.expanduser("~"), defaultFile=default_file, wildcard="*",
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as fileDialog:
Expand Down
2 changes: 2 additions & 0 deletions atbswp/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def on_settings_click(self, event):
"""Triggered when the popup menu is clicked."""
self.settings_popup()
event.GetEventObject().PopupMenu(self.settings_popup())
event.EventObject.Parent.panel.SetFocus()
event.Skip()

def settings_popup(self):
Expand Down Expand Up @@ -215,6 +216,7 @@ def __add_bindings(self):
self.Bind(wx.EVT_CLOSE, self.on_close_dialog)

self.panel.Bind(wx.EVT_KEY_UP, self.on_key_press)
self.panel.SetFocus()

def __set_properties(self):
self.file_open_button.SetSize(self.file_open_button.GetBestSize())
Expand Down

0 comments on commit 8a127fa

Please sign in to comment.