react-native-macos icon indicating copy to clipboard operation
react-native-macos copied to clipboard

Shortcuts / Basic shortcuts

Open jerrygreen opened this issue 5 years ago • 2 comments

There are some basic shortcuts like ⌘C, ⌘V, etc

Also, in web there are form tags which helps to handle Enter key – to send the form. Is there a good way to handle this with react-native-macos?

So the issue is more like 3 questions:

  1. Is it possible to enable such basic hotkeys? (⌘C, ⌘V, etc)
  2. How to properly handle inputs? (to send forms with Enter on any input instead of pressing buttons with cursor)
  3. What about custom hotkeys? It looks like it's possible. Any examples? Any docs? (I feel some lack of docs for react-native-macos – this is pretty sad because I really like this project)

jerrygreen avatar Nov 03 '18 07:11 jerrygreen

  1. Yes. You need to add TextInput, and if you have a menu Edit in your app, it'll provide all such functionality.
  2. Right now it requires some tweak in the core or writing your own native code. I can help with that, if you have a demo project.
  3. Hotkeys are definitely possible. It's again can be achieved with the menu https://github.com/ptmt/react-native-macos/blob/master/RNTester/js/MenuExample.macos.js#L25 or with the global hotkey handler even when your app is in background. Let me know if you're interested in a custom native module for that.

ptmt avatar Nov 03 '18 13:11 ptmt

and if you have a menu Edit in your app

How do I have it? I have TextInput but should I somehow enable these menus?

jerrygreen avatar Nov 04 '18 07:11 jerrygreen