diff --git a/Mirivoice/Views/SingleLineEditorView.axaml b/Mirivoice/Views/SingleLineEditorView.axaml index d3da0aa..7d70414 100644 --- a/Mirivoice/Views/SingleLineEditorView.axaml +++ b/Mirivoice/Views/SingleLineEditorView.axaml @@ -8,6 +8,6 @@ x:Class="Mirivoice.SingleLineEditorView"> - + diff --git a/Mirivoice/Views/SingleLineEditorView.axaml.cs b/Mirivoice/Views/SingleLineEditorView.axaml.cs index c5fe573..41e7d79 100644 --- a/Mirivoice/Views/SingleLineEditorView.axaml.cs +++ b/Mirivoice/Views/SingleLineEditorView.axaml.cs @@ -25,8 +25,9 @@ public SingleLineEditorView(LineBoxView l, bool FirstUpdate = true) this.FirstUpdate = FirstUpdate; } + bool ShouldPhonemizeWhenOutFocused = false; - private async void LineTextChanged(object sender, TextChangedEventArgs e) + private async void LineTextChanging(object sender, TextChangingEventArgs e) { l.DeActivatePhonemizer = false; @@ -38,11 +39,11 @@ private async void LineTextChanged(object sender, TextChangedEventArgs e) } if (l.lastPhonemizedText != l.viewModel.LineText) { - l.ShouldPhonemize = true; + ShouldPhonemizeWhenOutFocused = true; } if (l.ShouldPhonemize && !l.DeActivatePhonemizer) { - await Task.Run(() => l.viewModel.phonemizer.PhonemizeAsync(viewModel.mTextBoxEditor.CurrentScript, l)); + ShouldPhonemizeWhenOutFocused = true; } l.viewModel.LineText = viewModel.mTextBoxEditor.CurrentScript; @@ -50,7 +51,13 @@ private async void LineTextChanged(object sender, TextChangedEventArgs e) private void LineLostFocus(object sender, RoutedEventArgs e) { + l.viewModel.LineText = viewModel.mTextBoxEditor.CurrentScript; //Log.Debug("SingleLineTBox Lost Focus"); + if (l.lastPhonemizedText != l.viewModel.LineText) + { + l.DeActivatePhonemizer = false; + ShouldPhonemizeWhenOutFocused = true; + } if (FirstUpdate) { @@ -58,12 +65,16 @@ private void LineLostFocus(object sender, RoutedEventArgs e) Task.Run(() => l.viewModel.phonemizer.PhonemizeAsync(viewModel.mTextBoxEditor.CurrentScript, l)); return; } - + if (ShouldPhonemizeWhenOutFocused) + { + l.ShouldPhonemize = true; + ShouldPhonemizeWhenOutFocused = false; + } if (! l.DeActivatePhonemizer || l.MResultsCollection.Count == 0 && !string.IsNullOrEmpty(l.viewModel.LineText)) { l.ShouldPhonemize = true; - + return; }