Pressing Delete key on keyboard not working

So here’s a question for an adept Python coder…
I was paging through modules and found what looks like keybindings defined in the
C:\Program Files\GrampsAIO64-5.1.3\gramps\gui\viewmanager.py
(Win10 installed Gramps 5.1.3) starting at line 351

    def __init_lists(self):
        """
        Initialize the actions lists for the UIManager
        """
        self._app_actionlist = [
            ('quit', self.quit, None if is_quartz() else "<PRIMARY>q"),
            ('preferences', self.preferences_activate),
            ('about', self.display_about_box), ]

        self._file_action_list = [
            #('FileMenu', None, _('_Family Trees')),
            ('Open', self.__open_activate, "<PRIMARY>o"),
            #('OpenRecent'_("Open an existing database")),
            #('quit', self.quit, "<PRIMARY>q"),
            #('ViewMenu', None, _('_View')),

.
.
.
and so forth

Is it likely that I could disable the Ctrl-w hotkey by commenting out a line of the following lines starting at #384:

        self._readonly_action_list = [
            ('Close', self.close_database, "<control>w"),
            ('Export', self.export_data, "<PRIMARY>e"),

and @Mihle might be able to achieve his/her tweak by modifying lines around #404:

            #('<PRIMARY>BackSpace', self.__keypress, '<PRIMARY>BackSpace'),
            #('<PRIMARY>Delete', self.__keypress, '<PRIMARY>Delete'),
            #('<PRIMARY>Insert', self.__keypress, '<PRIMARY>Insert'),
            #('<PRIMARY>J', self.__keypress, '<PRIMARY>J'),

hmmm… those lines look like they’re already commented out. They’re also in the self._readonly_action_list section. So his/her Ctrl-delete would be in another subsection.

That would be great.

I’d also like Gramps to support the GtkShortcutsWindow dialog — which shows help for shortcuts.

What “Window” manager?

Default “Delete any kind of selected object” are the “Del”/“Delete” keyboard button in Windows not the combination of the CTRL and Del keyboard buttons (often written as “CTRL + Del”), it has always been so.
the “CTRL + Del” or “CTRL + Backspace” have as long as I remember been the shortcut combination for deleting the next whole word, not the selected text or selected object.

The strange thing in Gramps is that while in an editor, the Del/Delt key do delete the character to the right for the cursor in a text field, and it REMOVE an OBJECT, the same is the behavior for the CTRL + Del, it remove an object from a list, it do not delete it from any lists in an Editor Window, but “Del” does not remove/delete an object from the main list views, to remove/delete an object in the main list view, you need to use CTRL + Del.

So there are a clear inconsistency for the use of the “Del/Delete” button and the keyboard key combination of CTRL + Del.

There are other software that also use the CTRL + Del combination for delete selected object, so Gramps are not unique, but in Windows Explorer and most other places “Del” is the button for deleting a selected object, and CTRL + Del are the keyboard key combination for deleting the next word to the right of the curser.

After searching a little it seems that the GTK is where the key binding find place, and in GTK+, that can be controlled in a CSS.
And for me it looks like this is something that’s controlled/set by the developer of the software.

1 Like

Effectively, we can override this. I was not able to find what you found.

< PRIMARY > means < Control >
What is exactly PRIMARY? (< primary > for UNIX, Linux and macOS)

1 Like

Regarding the View and ‘Delete’ key; the reason this is set to <ctrl>Delete is because Gtk (our GUI library) processes keystrokes in a largest to smallest enclosed widget order.

So a simple ‘Delete’ key entered in a view (largest widget), while it would work, (if coded that way), would also prevent the user from using the ‘Delete’ key in any of the editable text fields (small enclosed widgets) anywhere within the view (like in the filters section, or any Gramplets that are part of the view). If you tried to delete a character in the text widget, you would end up trying to delete the active line in the view instead.

You can test this yourself, by modifying the code in C:\Program Files\GrampsAIO64-5.1.3\gramps\gui\views\listview.py at line 211 by removing the <Primary> from the ('Remove', self.remove, '<Primary>Delete'), line.

Developers have to fully understand the rules that the code uses when assigning keyboard shortcuts, otherwise trouble can occur.

3 Likes

I believe you, no problem with that…

I just don’t understand why gtk are like that, after you explain it…

Maybe time to port Gramps to something else than GTK as GUI? yes, I know that’s a really big job, but it seems that GTK have some limitations and strange behavior when you use it crossplatform…?
Any of you thought about mono or some other cross platform system?

PS. this is no critic of Gramps or your Choice, I’'m just curious, trying to learn a little more. and I just see that there are more GTK software ported to i.e. Windows that has some strange behavior… One I tried overtook the color and font theme of another software that also used GTK…

1 Like