dissent icon indicating copy to clipboard operation
dissent copied to clipboard

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

Open UInt2048 opened this issue 2 years ago • 7 comments

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?

UInt2048 avatar Apr 13 '23 10:04 UInt2048

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?

diamondburned avatar Apr 13 '23 23:04 diamondburned

@diamondburned <Ctrl> is the control key. <Meta> is the command key.

UInt2048 avatar Apr 15 '23 20:04 UInt2048

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

^C and ^P are copy and paste.

UInt2048 avatar Apr 15 '23 21:04 UInt2048

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?

dtonon avatar Jun 27 '24 16:06 dtonon

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.

diamondburned avatar Jun 28 '24 11:06 diamondburned

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.

dtonon avatar Jun 28 '24 11:06 dtonon

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

diamondburned avatar Jun 28 '24 15:06 diamondburned