xiaoyifang / goldendict-ng

The Next Generation GoldenDict
https://xiaoyifang.github.io/goldendict-ng/
Other
1.64k stars 90 forks source link

On Mac, `Cmd+C+C` disables system-wide "copy" shortcut. #325

Closed ElhemEnohpi closed 1 week ago

ElhemEnohpi commented 1 year ago

I installed GoldenDict on my Mac (thanks!), and found that it disables the "command-C" keyboard shortcut system-wide, when it's running. It's not possible to copy anything to the clipboard from any application, including GoldenDict itself. Disallowing the "control this computer" permission doesn't help. I had to disable the "translate word from clipboard" hotkey (double command-C) in the GoldenDict settings. It wasn't obvious at first, why the "copy" function of my computer was not working, and it took me some time to track it to GoldenDict, and then to the hotkey.

It looks like this was mentioned in #124 and #219.

If I remember correctly, I was asked to allow GoldenDict to "control this computer" after installing it. I think I did at first, but then turned it off in the macOS Settings, because I didn't see why it was necessary. Now, turning it back on has no effect; it makes no difference if it's on or off. If it's off, I'm not asked again to turn it on. The "translate word from clipboard" hotkey works anyway, either way, and the system-wide "copy" shortcut is disabled either way. The only fix is to disable the hotkey in GoldenDict. This should probably be the default for Mac, until it's fixed, as it's rather unexpected and disruptive.

PS, GoldenDict should have Cut, Copy, Paste, etc. in the Edit menu. This is expected of all applications that have those functions.

Mac M1 with macOS 13.2

Goldendict 22.12.24-alpha.230125.0e1ce782 macos darwin 22.3.0 Qt 6.4.2 arm64-little_endian-lp64 Clang 13.0.0 (clang-1300.0.29.30) Flags: MAKE_ZIM_SUPPORT MAKE_CHINESE_CONVERSION_SUPPORT

shenlebantongying commented 1 year ago

Temporary workaround: Just set the hotkey to a single combo -> like Command + G, then you can use Command+C Command+G and at the same time system copy-paste works.

https://user-images.githubusercontent.com/20123683/2102907-f461dbbd-0846-4302-8c74-efc20cee696b.mov

ElhemEnohpi commented 1 year ago

Thanks. Just disabling it works for me, I don't really need it. The main thing is that it's pretty disruptive for an application to disable the system-wide copy key function, so I suggest disabling it by default, or at least warning Mac users, until it can be fixed in the future.

It took me quite some time to figure out what was going on. I had installed it and left it running, and didn't notice the copying problem until the next day. At first I thought my web browser was broken and I was troubleshooting extensions, then realized it was every app, thought it was one of my other hotkey-related applications, and finally tracked it down to the problem in GoldenDict. It would have been nice to have a heads-up about it sooner.

xiaoyifang commented 1 year ago

Will enable it through accessories can solve this?

shenlebantongying commented 1 year ago

Not the root cause, but what I can observe:

Press Ctrl+C+C for the first time will show up this "Accessibility" permission dialog (Note that GD doesn't exist on the left):

Screenshot 2023-05-31 at 6 37 20 AM

If user denies at here, the system ctrl+C "copy" will no long works. (Note that the GD now exist on the list):

Because macOS already remembered GD don't have such permission. The permission request dialog won't show up anymore, thus silently crippling user's system level Ctrl+C copy. Then we get related bug reports.

Screenshot 2023-05-31 at 6 39 56 AM

I haven't tested again yet, but it appears that Apple would not consider the .dmg we built the same app (because no developer ID associated? I don't know). This permission need to be added again after each install.


To fix this, someone needs to write some native macOS code that checks and requests this permission actively, instead of relying on macOS'a automatic permission request dialog passively.

Or, investigate why lacking this permission cripples clipboard :sweat_smile:

Or, we display a warning dialog when the clipboard is empty (unable to read?) after pressing Ctrl+C+C


Before this happens, I think we should disable it by default.

shenlebantongying commented 1 week ago

For unknown reason, one may need to turn the accessibility permission off and on again

https://github.com/xiaoyifang/goldendict-ng/issues/630#issuecomment-1581367468

shenlebantongying commented 1 week ago

Ok, now GD will popup a message, which tells the user what to do, if GD is going to "eat" the Cmd+C.

Maybe there is a better way to do it (like not requiring accessibility permission at all), but I don't see it (based on my current limited knowledge).

Better solutions are welcomed.