OSDN Git Service

UWP版で時々IMEが意図したところに入力されないバグがあった
authorsabinekonya <test@hotmail.co.jp>
Wed, 13 Dec 2017 06:13:48 +0000 (15:13 +0900)
committersabinekonya <test@hotmail.co.jp>
Wed, 13 Dec 2017 06:13:48 +0000 (15:13 +0900)
UWP/FooEditEngine.UWP/FooTextBox.cs

index 8b86a23..4bcd48c 100644 (file)
@@ -111,6 +111,9 @@ namespace FooEditEngine.UWP
             this.timer.Tick += this.timer_Tick;
             this.timer.Start();
 
+            this.GettingFocus += FooTextBox_GettingFocus;
+            this.LosingFocus += FooTextBox_LosingFocus;
+
             this.SizeChanged += FooTextBox_SizeChanged;
 
             this.Loaded += FooTextBox_Loaded;
@@ -437,13 +440,16 @@ namespace FooEditEngine.UWP
             }
         }
 
-            /// <inheritdoc/>
-        protected override async void OnGotFocus(RoutedEventArgs e)
+        private void FooTextBox_LosingFocus(UIElement sender, LosingFocusEventArgs args)
         {
-            base.OnGotFocus(e);
+            this.RemoveTextContext();
 
-            System.Diagnostics.Debug.WriteLine("got focus");
+            System.Diagnostics.Debug.WriteLine("losing focus");
+        }
 
+        private async void FooTextBox_GettingFocus(UIElement sender, GettingFocusEventArgs args)
+        {
+            System.Diagnostics.Debug.WriteLine("getting focus");
             if (this.textServiceManager == null)
             {
                 await Task.Delay(500);
@@ -452,6 +458,14 @@ namespace FooEditEngine.UWP
             }
 
             this.CreateTextContext();
+        }
+
+        /// <inheritdoc/>
+        protected override void OnGotFocus(RoutedEventArgs e)
+        {
+            base.OnGotFocus(e);
+
+            System.Diagnostics.Debug.WriteLine("got focus");
 
             this.View.IsFocused = true;
             this.timer.Interval = new TimeSpan(0, 0, 0, 0, Interval);
@@ -465,13 +479,11 @@ namespace FooEditEngine.UWP
             this.CreateTextContext();
         }
 
-        /// <inheritdoc/>
+       /// <inheritdoc/>
         protected override void OnLostFocus(RoutedEventArgs e)
         {
             base.OnLostFocus(e);
 
-            this.RemoveTextContext();
-
             System.Diagnostics.Debug.WriteLine("lost focus");
             
             this.View.IsFocused = false;