mirror of
https://github.com/kk7ds/chirp
synced 2026-08-13 17:51:36 -04:00
Support Shift+F10 convention for context menu in memedit
This commit is contained in:
parent
bae48c6cd4
commit
8f442c8e09
1 changed files with 33 additions and 0 deletions
|
|
@ -1003,6 +1003,11 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
|
|||
self._memory_rclick)
|
||||
self._grid.Bind(wx.grid.EVT_GRID_CELL_BEGIN_DRAG, self._memory_drag)
|
||||
self.Bind(wx.EVT_KEY_DOWN, self._keyboard_overrides)
|
||||
# Bind key events on the inner grid window so the context-menu key
|
||||
# (WXK_WINDOWS_MENU / Apps key) and Shift+F10 reach our handler even
|
||||
# though focus lives inside the grid widget rather than on the panel.
|
||||
self._grid.GetGridWindow().Bind(wx.EVT_KEY_DOWN,
|
||||
self._keyboard_overrides)
|
||||
row_labels = self._grid.GetGridRowLabelWindow()
|
||||
row_labels.Bind(wx.EVT_LEFT_DOWN, self._row_click)
|
||||
row_labels.Bind(wx.EVT_LEFT_UP, self._row_click)
|
||||
|
|
@ -1153,9 +1158,37 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
|
|||
# wx.grid.Grid() can do it.
|
||||
# https://github.com/wxWidgets/wxWidgets/issues/22625
|
||||
self.cb_copy(cut=False)
|
||||
elif event.GetKeyCode() == wx.WXK_WINDOWS_MENU or (
|
||||
event.GetKeyCode() == wx.WXK_F10 and event.ShiftDown()):
|
||||
# Apps key or Shift+F10: open the context menu at the cursor cell.
|
||||
# EVT_GRID_CELL_RIGHT_CLICK never fires for keyboard users, so we
|
||||
# handle it here instead. Both the panel binding and the inner
|
||||
# grid-window binding point here, ensuring the event is caught
|
||||
# regardless of which sub-window holds focus.
|
||||
self._show_context_menu_at_cursor()
|
||||
else:
|
||||
event.Skip()
|
||||
|
||||
def _show_context_menu_at_cursor(self):
|
||||
"""Open the right-click context menu at the focused grid cell.
|
||||
|
||||
_memory_rclick() uses event.GetRow() which is only valid for actual
|
||||
mouse events. This method calls the same menu-building logic but
|
||||
substitutes the keyboard cursor position, so keyboard users (including
|
||||
screen reader users) get full access to all context-menu actions via
|
||||
the Apps key or Shift+F10.
|
||||
"""
|
||||
row = self._grid.GetGridCursorRow()
|
||||
if row < 0:
|
||||
return
|
||||
# Build a fake event-like object that satisfies _memory_rclick's
|
||||
# use of GetRow(), then delegate to the shared menu builder.
|
||||
|
||||
class _FakeGridEvent:
|
||||
def GetRow(self_):
|
||||
return row
|
||||
self._memory_rclick(_FakeGridEvent())
|
||||
|
||||
def _row_click(self, event):
|
||||
# In order to override the drag-to-multi-select behavior of the base
|
||||
# grid, we need to basically reimplement what happens when a user
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue