Skip to content

Commit

Permalink
Improved keyboard navigation for settings editor
Browse files Browse the repository at this point in the history
  • Loading branch information
kk7ds committed Jan 15, 2025
1 parent 47da494 commit 4faac35
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions chirp/wxui/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ def __init__(self, settinggroup, *a, **k):
self.pg.Bind(wx.propgrid.EVT_PG_CHANGED, self._pg_changed)
self.pg.Bind(wx.EVT_MOTION, self._mouseover)

self.pg.DedicateKey(wx.WXK_TAB)
self.pg.DedicateKey(wx.WXK_RETURN)
self.pg.DedicateKey(wx.WXK_UP)
self.pg.DedicateKey(wx.WXK_DOWN)
self.pg.AddActionTrigger(wx.propgrid.PG_ACTION_EDIT, wx.WXK_RETURN)
self.pg.AddActionTrigger(wx.propgrid.PG_ACTION_NEXT_PROPERTY,
wx.WXK_RETURN)

sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(sizer)
sizer.Add(self.pg, 1, wx.EXPAND)
Expand Down
8 changes: 8 additions & 0 deletions chirp/wxui/memedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,14 @@ def __init__(self, memedit, memories, *a, **k):
self._pg = wx.propgrid.PropertyGrid(self._tabs,
style=wx.propgrid.PG_BOLD_MODIFIED)
self._pg.Bind(wx.propgrid.EVT_PG_CHANGED, self._mem_prop_changed)

self._pg.DedicateKey(wx.WXK_RETURN)
self._pg.DedicateKey(wx.WXK_UP)
self._pg.DedicateKey(wx.WXK_DOWN)
self._pg.AddActionTrigger(wx.propgrid.PG_ACTION_EDIT, wx.WXK_RETURN)
self._pg.AddActionTrigger(wx.propgrid.PG_ACTION_NEXT_PROPERTY,
wx.WXK_RETURN)

self._tabs.InsertPage(0, self._pg, _('Values'))
page_index = 0
self._extra_page = None
Expand Down
11 changes: 11 additions & 0 deletions chirp/wxui/settingsedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@ def __init__(self, radio, *a, **k):
self._group_control = wx.Treebook(self, style=wx.LB_LEFT)
self._group_control.GetTreeCtrl().SetMinSize((250, -1))
sizer.Add(self._group_control, 1, wx.EXPAND)
self._group_control.GetTreeCtrl().Bind(wx.EVT_KEY_DOWN,
self._key)

self._initialized = False
self._restore_selection = None

def _key(self, event):
if event.GetKeyCode() in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER):
self._group_control.GetCurrentPage().SetFocus()
event.Skip()

def _initialize(self, job):
self.stop_wait_dialog()
with common.error_proof(Exception):
Expand All @@ -53,6 +60,10 @@ def _initialize(self, job):
self._group_control.SetSelection(self._restore_selection)
self._restore_selection = None

# Focus the selector after it loads
tc = self._group_control.GetTreeCtrl()
wx.CallAfter(tc.SetFocus)

def selected(self):
if not self._initialized:
self._initialized = True
Expand Down

0 comments on commit 4faac35

Please sign in to comment.