[fixed] Ticket #4683 - Mac keyboard Delete button unrecognized within Tools->Customize->Keyboard

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
doia
Posts: 251
Joined: Sat May 29, 2021 5:47 am
Location: Düsseldorf

[fixed] Ticket #4683 - Mac keyboard Delete button unrecognized within Tools->Customize->Keyboard

Post by doia »

Hi, I try to set some custom keyboard shortcuts and would like to set the deletion of objects to the Delete key. On Mac, the default Delete key is not recognized.

does not recognize Delete key
does not recognize Delete key
Bildschirmfoto 2021-05-31 um 17.55.41.png (167.5 KiB) Viewed 3797 times

Only if pressed in combination with the Fn key. Could this be a bug?

accepts Delete key only in combination with Fn key
accepts Delete key only in combination with Fn key
Bildschirmfoto 2021-05-31 um 17.56.02.png (194.03 KiB) Viewed 3797 times

I am using the ProDark theme, but the behavior is reproducible with no style sheet set as well.

OS: macOS 10.16
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: (HEAD detached at 0.19.2)
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.8
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
Last edited by doia on Wed Mar 09, 2022 9:27 pm, edited 3 times in total.
edwilliams16
Veteran
Posts: 3107
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: [Bug?] Mac keyboard Delete button is not recognized, only in combination with Fn button

Post by edwilliams16 »

It is standard Mac keyboard mapping. Mac delete = PC backspace, Mac Fn-Delete = PC Delete https://support.apple.com/en-gb/HT201236
I thought ctrl-d might work for Fn-delete, but it doesn't seem to.
Full-size Mac external keyboards have a delete-right key.
User avatar
doia
Posts: 251
Joined: Sat May 29, 2021 5:47 am
Location: Düsseldorf

Re: [Bug?] Mac keyboard Delete button is not recognized, only in combination with Fn button

Post by doia »

edwilliams16 wrote: Mon May 31, 2021 9:16 pm It is standard Mac keyboard mapping. Mac delete = PC backspace, Mac Fn-Delete = PC Delete https://support.apple.com/en-gb/HT201236
Understood and correct.

But shouldn't I be able to set Mac Delete/PC Backspace as a valid single key for triggering the Delete action? Yet FC does not recognize this single key, just displays "none". I don't know if it is possible on a Linux/Windows system. Could you check, if you work on such a system?

The why: Just a personal preference/habit known from other software, e.g. Revit allows deleting an element by pressing the Mac Delete key.
chrisb
Veteran
Posts: 53928
Joined: Tue Mar 17, 2015 9:14 am

Re: [Bug?] Mac keyboard Delete button is not recognized, only in combination with Fn button

Post by chrisb »

doia wrote: Tue Jun 01, 2021 7:44 am But shouldn't I be able to set Mac Delete/PC Backspace as a valid single key for triggering the Delete action? Yet FC does not recognize this single key, just displays "none". I don't know if it is possible on a Linux/Windows system. Could you check, if you work on such a system?
This is out of the scope of FreeCAD: you can freely configure the keyboard layout on MacOS with a keyboard layout XML file.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
doia
Posts: 251
Joined: Sat May 29, 2021 5:47 am
Location: Düsseldorf

Re: [Bug?] Mac keyboard Delete button is not recognized, only in combination with Fn button

Post by doia »

I don't think it has anything to do with keyboard layout definitions, as I will not change the layout (e.g. map the backspace key to the x key). Maybe I misstated my problem. The Mac Delete key is not recognized within the FC Tools->Customize->Keyboard screen.

The key is recognized in other screens or workbenches, as I can use Mac Delete within the Spreadsheet WB or in any other WB where I have to enter a value into a field. If pressed, the character left of the cursor gets deleted. Just as expected.

Other programs like Blender or Inkscape recognize the Mac Delete key for keyboard shortcut settings, without any change in keyboard layout XML files.
martin51
Posts: 70
Joined: Sun May 03, 2020 8:45 pm
Location: Irvine, California

Re: [Bug] Mac keyboard Delete button is not recognized within Tools->Customize->Keyboard, only in combination with Fn bu

Post by martin51 »

Editing FreeCAD's user.cfg file to remap the delete key worked for me:

<FCParamGroup Name="Shortcut">
<FCText Name="Std_Delete">Backspace</FCText>
</FCParamGroup>
User avatar
doia
Posts: 251
Joined: Sat May 29, 2021 5:47 am
Location: Düsseldorf

Re: [Bug] Mac keyboard Delete button is not recognized within Tools->Customize->Keyboard, only in combination with Fn bu

Post by doia »

Thank you @martin51, that works. I can now delete elements with just pressing the Mac Delete key, e.g. deleting lines in the Sketcher WB.

So the bug is confirmed. FC on Mac can read and interpret the Mac Delete (aka Backspace) key without additionally pressing the FN key, if set manually in the Library/Preferences/Freecad/user.cfg file. But this key is not recognised within the FC Tools->Customize->Keyboard interface, which should be able use this key to set it in the user.cfg file.

I will file a bug in the tracker.
edwilliams16
Veteran
Posts: 3107
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: [Bug] Mac keyboard Delete button is not recognized within Tools->Customize->Keyboard, only in combination with Fn bu

Post by edwilliams16 »

If anybody else wants to do this, note that FreeCAD cannot be open when you edit user.cfg or your changes will be over-written when FreeCAD closes.
User avatar
doia
Posts: 251
Joined: Sat May 29, 2021 5:47 am
Location: Düsseldorf

Re: [Bug] Mac keyboard Delete button is not recognized within Tools->Customize->Keyboard, only in combination with Fn bu

Post by doia »

:lol: Yep, had to learn that too. Took me 3 attempts until I closed FC before editing user.cfg
User avatar
chennes
Veteran
Posts: 3879
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [Bug] Mac keyboard Delete button is not recognized within Tools->Customize->Keyboard, only in combination with Fn bu

Post by chennes »

The culprit here seems to be the following code in AccelLineEdit.cpp:

Code: Select all

// Backspace clears the shortcut
    // If a modifier is pressed without any other key, return.
    // AltGr is not a modifier but doesn't have a QtSring representation.
    switch(key) {
    case Qt::Key_Backspace:
        if (state == Qt::NoModifier) {
            keyPressedCount = 0;
            setText(noneStr);
        }
So it is not possible to set "Backspace" (Mac "Delete") as a keyboard shortcut on any OS, it would appear -- not because of a Qt limitation, but because that's explicitly how the Accelerator line edit work.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply