/// <summary> /// Captures the all key downs and Ups. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnAcceleratorKeyActivated(object sender, KeyEventArgs e) { if (ReactInstanceManager.DevSupportManager.IsEnabled) { var isCtrlKeyDown = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control; //Ctrl+D or Ctrl+M if (isCtrlKeyDown && (e.Key == Key.D || e.Key == Key.M)) { ReactInstanceManager.DevSupportManager.ShowDevOptionsDialog(); } // Ctrl+R if (isCtrlKeyDown && e.Key == Key.R) { ReactInstanceManager.DevSupportManager.HandleReloadJavaScript(); } } // Back button if (e.Key == Key.Back || e.Key == Key.BrowserBack) { ReactInstanceManager.OnBackPressed(); } }
/// <summary> /// Captures the all key downs and Ups. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void OnAcceleratorKeyActivated(object sender, KeyEventArgs e) { if (ReactInstanceManager.DevSupportManager.IsEnabled) { var isCtrlKeyDown = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control; //Ctrl+D or Ctrl+M if (isCtrlKeyDown && (e.Key == Key.D || e.Key == Key.M)) { ReactInstanceManager.DevSupportManager.ShowDevOptionsDialog(); } // Ctrl+R if (isCtrlKeyDown && e.Key == Key.R) { await ReactInstanceManager.DevSupportManager.CreateReactContextFromPackagerAsync(CancellationToken.None); } } // Back button if (e.Key == Key.Back || e.Key == Key.BrowserBack) { ReactInstanceManager.OnBackPressed(); } }
/// <summary> /// Called when the application is first initialized. /// </summary> /// <param name="arguments">The launch arguments.</param> /// <param name="initialProps">The initialProps.</param> public void OnCreate(string arguments, JObject initialProps) { RootView.Background = (Brush)Application.Current.Resources["ApplicationPageBackgroundThemeBrush"]; ApplyArguments(arguments); RootView.StartReactApplication(_reactInstanceManager, MainComponentName, initialProps); SystemNavigationManager.GetForCurrentView().BackRequested += (sender, args) => { _reactInstanceManager.OnBackPressed(); args.Handled = true; }; Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += OnAcceleratorKeyActivated; }