ptmt / react-native-macos

[deprecated in favor of https://microsoft.github.io/react-native-windows/] React Native for macOS is an experimental fork for writing desktop apps using Cocoa
MIT License
11.25k stars 429 forks source link

Shortcuts / Basic shortcuts #214

Open jerrygreen opened 5 years ago

jerrygreen commented 5 years ago

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)
ptmt commented 5 years ago
  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.
jerrygreen commented 5 years ago

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?