Save and restore the value of EquationInputArea when users scroll (#866)
* Save and restore the value of EquationInputArea when users scroll * clean up * replace ->Focus(..) by FocusManager::TryFocus(...)
This commit is contained in:
@@ -243,6 +243,7 @@
|
||||
KeyGraphFeaturesButtonClicked="EquationTextBox_KeyGraphFeaturesButtonClicked"
|
||||
Loaded="InputTextBox_Loaded"
|
||||
LostFocus="InputTextBox_LostFocus"
|
||||
MathEquation="{x:Bind Expression, Mode=TwoWay}"
|
||||
RemoveButtonClicked="EquationTextBox_RemoveButtonClicked">
|
||||
<controls:EquationTextBox.ColorChooserFlyout>
|
||||
<Flyout x:Name="ColorChooserFlyout"
|
||||
|
@@ -84,7 +84,7 @@ void EquationInputArea::InputTextBox_LostFocus(Object ^ sender, RoutedEventArgs
|
||||
KeyboardShortcutManager::HonorShortcuts(true);
|
||||
}
|
||||
|
||||
void EquationInputArea::InputTextBox_Submitted(Object ^ sender, EquationSubmissionSource source)
|
||||
void EquationInputArea::InputTextBox_Submitted(Object ^ sender, MathRichEditBoxSubmission ^ submission)
|
||||
{
|
||||
auto tb = static_cast<EquationTextBox ^>(sender);
|
||||
if (tb == nullptr)
|
||||
@@ -97,16 +97,8 @@ void EquationInputArea::InputTextBox_Submitted(Object ^ sender, EquationSubmissi
|
||||
return;
|
||||
}
|
||||
|
||||
auto expressionText = tb->GetEquationText();
|
||||
if (source == EquationSubmissionSource::FOCUS_LOST && eq->Expression == expressionText)
|
||||
{
|
||||
// The expression didn't change.
|
||||
return;
|
||||
}
|
||||
|
||||
eq->Expression = expressionText;
|
||||
|
||||
if (source == EquationSubmissionSource::ENTER_KEY || eq->Expression != nullptr && eq->Expression->Length() > 0)
|
||||
if (submission->Source == EquationSubmissionSource::ENTER_KEY ||
|
||||
(submission->Source == EquationSubmissionSource::FOCUS_LOST && submission->HasTextChanged && eq->Expression != nullptr && eq->Expression->Length() > 0))
|
||||
{
|
||||
unsigned int index = 0;
|
||||
if (Equations->IndexOf(eq, &index))
|
||||
@@ -180,13 +172,6 @@ void EquationInputArea::EquationTextBox_RemoveButtonClicked(Object ^ sender, Rou
|
||||
void EquationInputArea::EquationTextBox_KeyGraphFeaturesButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
auto tb = static_cast<EquationTextBox ^>(sender);
|
||||
|
||||
// ensure the equation has been submitted before trying to get key graph features out of it
|
||||
if (tb->HasFocus)
|
||||
{
|
||||
EquationInputArea::InputTextBox_Submitted(sender, EquationSubmissionSource::FOCUS_LOST);
|
||||
}
|
||||
|
||||
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
|
||||
KeyGraphFeaturesRequested(this, eq);
|
||||
}
|
||||
|
@@ -38,9 +38,9 @@ namespace CalculatorApp
|
||||
|
||||
void AddNewEquation();
|
||||
|
||||
void InputTextBox_GotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void InputTextBox_LostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void InputTextBox_Submitted(Platform::Object ^ sender, CalculatorApp::Controls::EquationSubmissionSource e);
|
||||
void InputTextBox_GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void InputTextBox_LostFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void InputTextBox_Submitted(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxSubmission ^ e);
|
||||
|
||||
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^ sender, Platform::Object ^ args);
|
||||
void ReloadAvailableColors(bool isHighContrast);
|
||||
|
@@ -461,7 +461,7 @@ void GraphingCalculator::TraceValuePopup_SizeChanged(Object ^ sender, SizeChange
|
||||
|
||||
void CalculatorApp::GraphingCalculator::ActiveTracing_Checked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
GraphingControl->Focus(::FocusState::Programmatic);
|
||||
FocusManager::TryFocusAsync(GraphingControl, ::FocusState::Programmatic);
|
||||
|
||||
m_activeTracingKeyUpToken = Window::Current->CoreWindow->KeyUp +=
|
||||
ref new Windows::Foundation::TypedEventHandler<Windows::UI::Core::CoreWindow ^, Windows::UI::Core::KeyEventArgs ^>(
|
||||
|
@@ -32,7 +32,7 @@ void GraphingNumPad::ShiftButton_Uncheck(_In_ Platform::Object ^ /*sender*/, _In
|
||||
{
|
||||
ShiftButton->IsChecked = false;
|
||||
SetOperatorRowVisibility();
|
||||
ShiftButton->Focus(::FocusState::Programmatic);
|
||||
FocusManager::TryFocusAsync(ShiftButton, ::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
void GraphingNumPad::TrigFlyoutShift_Toggle(_In_ Platform::Object ^ /*sender*/, _In_ Windows::UI::Xaml::RoutedEventArgs ^ /*e*/)
|
||||
|
@@ -296,7 +296,7 @@ void MainPage::SetDefaultFocus()
|
||||
}
|
||||
if (m_graphingCalculator != nullptr && m_graphingCalculator->Visibility == ::Visibility::Visible)
|
||||
{
|
||||
m_graphingCalculator->Focus(::FocusState::Programmatic);
|
||||
FocusManager::TryFocusAsync(m_graphingCalculator, ::FocusState::Programmatic);
|
||||
}
|
||||
if (m_converter != nullptr && m_converter->Visibility == ::Visibility::Visible)
|
||||
{
|
||||
|
Reference in New Issue
Block a user