diamondburned / dissent

Tiny native Discord app
https://flathub.org/apps/details/so.libdb.dissent
GNU General Public License v3.0
1.25k stars 40 forks source link

[Feature Request] Change keyboard shortcuts to command key on macOS #126

Open UInt2048 opened 1 year ago

UInt2048 commented 1 year ago

I was very pleased to see this built on macOS (thanks to #66).

Shortcuts like ^P and ^Q would work much better in a macOS context if they were ⌘P and ⌘Q.

Can there be an option to change all control keyboard shortcuts in GTKCord4 with command?

diamondburned commented 1 year ago

I'm not even sure what ^P does. I think that might be a GTK thing. ^Q is controlled here along with ^P:

    // main.go
    m.app.AddActionShortcuts(map[string]string{
        "<Ctrl>K": "app.show-qs",
        "<Ctrl>Q": "app.quit",
    })

I'm not too sure which key macOS uses for Command if not Ctrl. Can you check gtk_accelerator_parse and experiment with it?

UInt2048 commented 1 year ago

@diamondburned \ is the control key. \ is the command key.

UInt2048 commented 1 year ago

I'm not even sure what ^P does. I think that might be a GTK thing.

^C and ^P are copy and paste.

dtonon commented 2 months ago

I'm also investigating how to add macos keybinding support to my app, that uses gotk4. This works fine:

    gtkutil.AddActionShortcuts(&w, map[string]string{
        "<Meta>K": "win.quick-switcher",
        "<Meta>Q": "win.quit",
    })

But I'm unable to target all the Text / TextView in the app, to map the copy/paste commands.

Any help, please?

diamondburned commented 2 months ago

Perhaps this article can help with changing <Ctrl> to <Meta>: https://gaphor.org/en/2022/12/10/gtk4-macos-keybindings/

It would probably be quite hard to target all Text/TextViews, but you can start with the message composer. AFAIK, that is the only significant TextView widget used in the program aside from messages. For messages, you want to look into changing chatkit.

dtonon commented 2 months ago

Thank you for the reply. I already found that article, and it seems proposing something similar to AddActionShortcuts method, but I'm not able to apply it to a single adw.EntryRow:

p.input = adw.NewEntryRow()
...
gtkutil.AddActionShortcuts(p.input, map[string]string{
    "<Meta>C": "win.copy",
    "<Meta>V": "win.paste",
})

PS: I'm trying this on a my app that uses gotk4-adwaita/gotk4/gotkit, not on dissent; sorry if I hijacked this thread, but was the only one I found about this specific issue.

diamondburned commented 2 months ago

Does win.copy and win.paste exist? I don't think GTK supplies those.