fixes up bug: Narrator is not reading the already entered equation when focus lands on Enter a equation edit box.

This commit is contained in:
MSFT-Tilia 2021-02-01 18:29:48 +08:00
commit 284e55a593
2 changed files with 13 additions and 0 deletions

View file

@ -72,6 +72,7 @@ MathRichEditBox::MathRichEditBox()
{ {
throw Exception::CreateException(hr); throw Exception::CreateException(hr);
} }
this->GotFocus += ref new RoutedEventHandler(this, &MathRichEditBox::OnGotFocus);
this->LosingFocus += ref new TypedEventHandler<UIElement ^,LosingFocusEventArgs ^>(this, &MathRichEditBox::OnLosingFocus); this->LosingFocus += ref new TypedEventHandler<UIElement ^,LosingFocusEventArgs ^>(this, &MathRichEditBox::OnLosingFocus);
this->KeyUp += ref new KeyEventHandler(this, &MathRichEditBox::OnKeyUp); this->KeyUp += ref new KeyEventHandler(this, &MathRichEditBox::OnKeyUp);
} }
@ -112,6 +113,16 @@ void MathRichEditBox::SetMathTextProperty(String ^ newValue)
this->IsReadOnly = readOnlyState; this->IsReadOnly = readOnlyState;
} }
void MathRichEditBox::OnGotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
{
// bug: https://dev.azure.com/microsoft/OS/_workitems/edit/28498627
// below directives on Selection are going to engage Narrator to announce the content of this richedit
// this is a workaround since richedit doesn't announce its content automatically.
this->Document->Selection->EndKey(TextRangeUnit::Line, false);
this->Document->Selection->HomeKey(TextRangeUnit::Line, false);
this->Document->Selection->MoveLeft(TextRangeUnit::Character, 1, false);
}
void MathRichEditBox::OnLosingFocus(UIElement ^ sender, LosingFocusEventArgs ^ args) void MathRichEditBox::OnLosingFocus(UIElement ^ sender, LosingFocusEventArgs ^ args)
{ {
if (this->IsReadOnly || this->ContextFlyout->IsOpen) if (this->IsReadOnly || this->ContextFlyout->IsOpen)
@ -122,6 +133,7 @@ void MathRichEditBox::OnLosingFocus(UIElement ^ sender, LosingFocusEventArgs ^ a
SubmitEquation(EquationSubmissionSource::FOCUS_LOST); SubmitEquation(EquationSubmissionSource::FOCUS_LOST);
} }
void MathRichEditBox::OnKeyUp(Object ^ sender, KeyRoutedEventArgs ^ e) void MathRichEditBox::OnKeyUp(Object ^ sender, KeyRoutedEventArgs ^ e)
{ {
if (!this->IsReadOnly && e->Key == VirtualKey::Enter) if (!this->IsReadOnly && e->Key == VirtualKey::Enter)

View file

@ -68,6 +68,7 @@ namespace CalculatorApp
void SetMathTextProperty(Platform::String ^ newValue); void SetMathTextProperty(Platform::String ^ newValue);
void OnLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args); void OnLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args);
void OnGotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnKeyUp(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e); void OnKeyUp(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e);
}; };
} }