Do not shadow focused text entries' Ctrl+C in list views#2446
Open
eduralph wants to merge 1 commit into
Open
Conversation
NavigationView's window-level key_press_handler consumed Ctrl+C before a focused sidebar/filter text entry could own the keystroke. This prevented standard text editing operations (Copy/Cut/Paste) in focused editables while list views were open. Add a focus check: if the focused widget is a Gtk.Editable or Gtk.TextView, return False to let the event propagate to the focused editable. When the list/tree itself holds focus, the object-copy behaviour is preserved. This restores the invariant that a window/view-level accelerator must not shadow the standard text-editing keystrokes of a focused text-editable widget — the focused editable owns Copy/Cut/Paste. Applies to all NavigationView subclasses (People, Families, Events, Places, Sources, Citations, Repositories, Media, Notes), not just one view. Fixes #6170 Signed-off-by: Eduard Ralph <eduard@ralphovi.net>
This was referenced Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
User impact: In any list view (People, Families, Events, Places, and so on), clicking into the sidebar or filter search box, selecting some text, and pressing Ctrl+C does not copy that text. Instead Gramps copies the highlighted list entry into its own clipboard and pops up the Clipboard window. Cut and paste work normally in the same box — only copy is hijacked, which blocks ordinary copy-and-paste while a list is open.
This makes a focused text box own Ctrl+C so it copies your selected text, while the list still copies the selected object when the list itself has focus.
Reported in Mantis #6170.
What to look at
The whole change is one focus check added to the shared list-view Ctrl+C handler: if a text box has focus, let the keystroke through to it instead of copying the selected list object. To try it:
Root cause
PageView.__init__()atpageview.py:131connects the key_press_handler to the toplevel window:GTK delivers key-press events to the toplevel before the focused child widget, so a window-level handler runs first.
NavigationViewoverrides this handler and, for Ctrl+C, unconditionally invokescall_copy()and consumes the event (return Trueat lines 487–489):The
return Truestops propagation, so a focused sidebar/filter entry never sees Ctrl+C.call_copy()then opens aClipboardWindowwhen a list object is selected, which is why the symptom is "Ctrl+C pops up the Clipboard."Fix
Before invoking object-copy,
NavigationView.key_press_handler(gramps/gui/views/navigationview.py:481–490) checks whether the focused widget is a text-editable. If it is, returnFalseto let GTK propagate the event to the focused editable, which performs standard text copy to the system clipboard. The fix (lines 488–498) is:This restores the invariant that a window/view-level accelerator must not shadow the standard text-editing keystrokes of a focused text-editable widget. The fix lives in the shared
NavigationView.key_press_handler, so it holds for all navigation list views (People, Families, Events, Places, Sources, Citations, Repositories, Media, Notes), not a single view.Verification
gramps/gui/views/pageview.py:131(connectskey_press_handlerto the toplevel window) andgramps/gui/views/navigationview.py:481–490(the handler override) onmaintenance/gramps61— the fix (lines 488–498) checks focus type beforecall_copy()at line 499 (unchanged).Gtk.Editable/Gtk.TextVieware the standard GTK text-editable base types; all sidebar/filter entries (e.g._searchbar.py:57builds aGtk.Entry) areGtk.Editableinstances, so returningFalselets the event propagate to them. Object-copy is preserved because theisinstance(focus, (Gtk.Editable, Gtk.TextView))check returnsFalsefor aGtk.TreeView, socall_copy()(line 499) andreturn True(line 500) execute unchanged.engine/interface/test_bug_0006170_sidebar_filter_copy.py, which asserts no top-level "Clipboard" frame appears after Ctrl+C in a focused sidebar entry — red on the unpatched target (the Clipboard window appears and the handler consumes Ctrl+C), green with the patch. Manual repro: People view → select a person → focus the sidebar Name entry → type and select text → Ctrl+C copies the text to the system clipboard.Fixes #6170