/* * private static void OnVisibilityChanged(object sender, VisibilityChangedEventArgs e) * { * System.Diagnostics.Debug.WriteLine("VISIBILITY: "+e.Visible); * } * * private static void OnActivated(object sender, WindowActivatedEventArgs e) * { * System.Diagnostics.Debug.WriteLine("ACTIVATED: "+e.WindowActivationState); * } */ #endregion #region Fields //Windows.UI.Xaml.Controls.Button _removeFocusControl; #endregion #region Connect / Disconnect void Connect(HardwareKeyPage element) { //ActiveInstances.Add(this); if (element != null) { Window.Current.CoreWindow.CharacterReceived += OnCharacterReceived; Window.Current.CoreWindow.KeyDown += OnKeyDown; //Window.Current.CoreWindow.KeyUp += CoreWindow_KeyUp; //var interceptor = Windows.UI.Input.KeyboardDeliveryInterceptor.GetForCurrentView(); //interceptor.KeyDown += OnInterceptorKeyDown; //interceptor.IsInterceptionEnabledWhenInForeground = true; /* * //HardwareKeyPage.SetNativeFocused = OnSetNativeFocused; * HardwareKeyPage.GetNativeFocused = OnGetNativeFocused; * * if (_removeFocusControl == null) * { * _removeFocusControl = new Windows.UI.Xaml.Controls.Button(); * Children.Add((_removeFocusControl)); * } */ } }
void Disconnect(HardwareKeyPage element) { //ActiveInstances.Remove(this); if (element != null) { /* * if (ActiveInstances.Count > 0) * HardwareKeyPage.RemoveNativeFocus = ActiveInstances.Last().OnRemoveNativeFocus; * else * HardwareKeyPage.RemoveNativeFocus = null; * _removeFocusControl = null; */ Window.Current.CoreWindow.CharacterReceived -= OnCharacterReceived; Window.Current.CoreWindow.KeyDown -= OnKeyDown; //Window.Current.CoreWindow.KeyUp -= CoreWindow_KeyUp; //var interceptor = Windows.UI.Input.KeyboardDeliveryInterceptor.GetForCurrentView(); //interceptor.KeyDown -= OnInterceptorKeyDown; //interceptor.IsInterceptionEnabledWhenInForeground = false; } }