Skip to content

Commit

Permalink
handle spacebar selection of cells properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Patronics authored and kk7ds committed Dec 16, 2024
1 parent ef72314 commit 48c3315
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions chirp/wxui/bankedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __init__(self, radio, *a, **k):

self._memory_cache = {}

self._grid.Bind(wx.grid.EVT_GRID_CELL_CHANGING, self._index_changed)
self._grid.Bind(wx.grid.EVT_GRID_CELL_CHANGING, self._cell_changing)
self._grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self._memory_changed)
self._grid.Bind(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK, self._label_click)
self._grid.GetGridColLabelWindow().Bind(wx.EVT_MOTION,
Expand Down Expand Up @@ -216,12 +216,19 @@ def change_bank_name(self, col, bank, name):
wx.CallAfter(self._grid.AutoSizeColumns, setAsMin=True)

@common.error_proof()
def _index_changed(self, event):
def _cell_changing(self, event):
row = event.GetRow()
col = event.GetCol()
value = event.GetString()
# if index value changed, update memory index
if isinstance(self._col_defs[col], ChirpBankIndexColumn):
self._change_memory_index(self.row2mem(row), int(value))
# if activating a checkbox with spacebar, treat it like a click
elif isinstance(self._col_defs[col], ChirpBankToggleColumn):
gridCellValue = self._grid.GetCellValue(row, col)
self._change_memory_mapping(self.row2mem(row),
self.col2bank(col),
gridCellValue != BANK_SET_VALUE)

def _change_memory_index(self, number, index):
for i, bank_index in enumerate(self._bank_index_order):
Expand Down

0 comments on commit 48c3315

Please sign in to comment.