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:
parent
534139d67d
commit
dbddc7bc86
@ -2101,6 +2101,7 @@
|
|||||||
FontWeight="{TemplateBinding FontWeight}"
|
FontWeight="{TemplateBinding FontWeight}"
|
||||||
AcceptsReturn="false"
|
AcceptsReturn="false"
|
||||||
InputScope="Text"
|
InputScope="Text"
|
||||||
|
MathText="{Binding MathEquation, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
||||||
MaxLength="2048"
|
MaxLength="2048"
|
||||||
TextWrapping="NoWrap">
|
TextWrapping="NoWrap">
|
||||||
<Controls:MathRichEditBox.ContextFlyout>
|
<Controls:MathRichEditBox.ContextFlyout>
|
||||||
|
@ -26,6 +26,7 @@ DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, ColorChooserFlyout);
|
|||||||
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, EquationButtonContentIndex);
|
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, EquationButtonContentIndex);
|
||||||
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, HasError);
|
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, HasError);
|
||||||
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, IsAddEquationMode);
|
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, IsAddEquationMode);
|
||||||
|
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, MathEquation);
|
||||||
|
|
||||||
EquationTextBox::EquationTextBox()
|
EquationTextBox::EquationTextBox()
|
||||||
{
|
{
|
||||||
@ -51,8 +52,9 @@ void EquationTextBox::OnApplyTemplate()
|
|||||||
{
|
{
|
||||||
m_richEditBox->GotFocus += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxGotFocus);
|
m_richEditBox->GotFocus += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxGotFocus);
|
||||||
m_richEditBox->LostFocus += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxLostFocus);
|
m_richEditBox->LostFocus += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxLostFocus);
|
||||||
m_richEditBox->TextChanged += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxTextChanged);
|
|
||||||
m_richEditBox->SelectionFlyout = nullptr;
|
m_richEditBox->SelectionFlyout = nullptr;
|
||||||
|
m_richEditBox->EquationSubmitted +=
|
||||||
|
ref new EventHandler<MathRichEditBoxSubmission ^>(this, &EquationTextBox::OnEquationSubmitted);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_equationButton != nullptr)
|
if (m_equationButton != nullptr)
|
||||||
@ -69,7 +71,7 @@ void EquationTextBox::OnApplyTemplate()
|
|||||||
|
|
||||||
if (m_richEditContextMenu != nullptr)
|
if (m_richEditContextMenu != nullptr)
|
||||||
{
|
{
|
||||||
m_richEditContextMenu->Opening += ref new Windows::Foundation::EventHandler<Platform::Object ^>(this, &EquationTextBox::OnRichEditMenuOpening);
|
m_richEditContextMenu->Opening += ref new EventHandler<Platform::Object ^>(this, &EquationTextBox::OnRichEditMenuOpening);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_kgfEquationButton != nullptr)
|
if (m_kgfEquationButton != nullptr)
|
||||||
@ -150,37 +152,6 @@ void EquationTextBox::OnPointerCaptureLost(PointerRoutedEventArgs ^ e)
|
|||||||
UpdateCommonVisualState();
|
UpdateCommonVisualState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationTextBox::OnKeyDown(KeyRoutedEventArgs ^ e)
|
|
||||||
{
|
|
||||||
if (e->Key == VirtualKey::Enter)
|
|
||||||
{
|
|
||||||
m_sourceSubmission = EquationSubmissionSource::ENTER_KEY;
|
|
||||||
// We will rely on OnLostFocus to submit the equation to prevent the launch of 2 events
|
|
||||||
if (!m_HasFocus || !FocusManager::TryMoveFocusAsync(::FocusNavigationDirection::Next))
|
|
||||||
{
|
|
||||||
m_sourceSubmission = EquationSubmissionSource::FOCUS_LOST;
|
|
||||||
EquationSubmitted(this, EquationSubmissionSource::ENTER_KEY);
|
|
||||||
if (m_functionButton && m_richEditBox->MathText != L"")
|
|
||||||
{
|
|
||||||
m_functionButton->IsEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EquationTextBox::OnLostFocus(RoutedEventArgs ^ e)
|
|
||||||
{
|
|
||||||
if (m_richEditBox == nullptr || m_richEditBox->ContextFlyout->IsOpen)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_functionButton && m_richEditBox->MathText != L"")
|
|
||||||
{
|
|
||||||
m_functionButton->IsEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EquationTextBox::OnColorFlyoutOpened(Object ^ sender, Object ^ e)
|
void EquationTextBox::OnColorFlyoutOpened(Object ^ sender, Object ^ e)
|
||||||
{
|
{
|
||||||
m_isColorChooserFlyoutOpen = true;
|
m_isColorChooserFlyoutOpen = true;
|
||||||
@ -194,15 +165,9 @@ void EquationTextBox::OnColorFlyoutClosed(Object ^ sender, Object ^ e)
|
|||||||
UpdateCommonVisualState();
|
UpdateCommonVisualState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationTextBox::OnRichEditBoxTextChanged(Object ^ sender, RoutedEventArgs ^ e)
|
|
||||||
{
|
|
||||||
UpdateButtonsVisualState();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EquationTextBox::OnRichEditBoxGotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationTextBox::OnRichEditBoxGotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
m_HasFocus = true;
|
m_HasFocus = true;
|
||||||
m_sourceSubmission = EquationSubmissionSource::FOCUS_LOST;
|
|
||||||
UpdateCommonVisualState();
|
UpdateCommonVisualState();
|
||||||
UpdateButtonsVisualState();
|
UpdateButtonsVisualState();
|
||||||
}
|
}
|
||||||
@ -216,8 +181,6 @@ void EquationTextBox::OnRichEditBoxLostFocus(Object ^ sender, RoutedEventArgs ^
|
|||||||
|
|
||||||
UpdateCommonVisualState();
|
UpdateCommonVisualState();
|
||||||
UpdateButtonsVisualState();
|
UpdateButtonsVisualState();
|
||||||
|
|
||||||
EquationSubmitted(this, m_sourceSubmission);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EquationTextBox::OnDeleteButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationTextBox::OnDeleteButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
@ -413,6 +376,19 @@ void EquationTextBox::FocusTextBox()
|
|||||||
{
|
{
|
||||||
if (m_richEditBox != nullptr)
|
if (m_richEditBox != nullptr)
|
||||||
{
|
{
|
||||||
m_richEditBox->Focus(::FocusState::Programmatic);
|
FocusManager::TryFocusAsync(m_richEditBox, ::FocusState::Programmatic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EquationTextBox::OnEquationSubmitted(Platform::Object ^ sender, MathRichEditBoxSubmission ^ args)
|
||||||
|
{
|
||||||
|
if (args->HasTextChanged)
|
||||||
|
{
|
||||||
|
if (m_functionButton && m_richEditBox->MathText != L"")
|
||||||
|
{
|
||||||
|
m_functionButton->IsEnabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EquationSubmitted(this, args);
|
||||||
|
}
|
||||||
|
@ -11,13 +11,6 @@ namespace CalculatorApp
|
|||||||
{
|
{
|
||||||
namespace Controls
|
namespace Controls
|
||||||
{
|
{
|
||||||
public
|
|
||||||
enum class EquationSubmissionSource
|
|
||||||
{
|
|
||||||
FOCUS_LOST,
|
|
||||||
ENTER_KEY
|
|
||||||
};
|
|
||||||
|
|
||||||
public
|
public
|
||||||
ref class EquationTextBox sealed : public Windows::UI::Xaml::Controls::Control
|
ref class EquationTextBox sealed : public Windows::UI::Xaml::Controls::Control
|
||||||
{
|
{
|
||||||
@ -28,6 +21,7 @@ namespace CalculatorApp
|
|||||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::SolidColorBrush ^, EquationColor);
|
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::SolidColorBrush ^, EquationColor);
|
||||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Controls::Flyout ^, ColorChooserFlyout);
|
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Controls::Flyout ^, ColorChooserFlyout);
|
||||||
DEPENDENCY_PROPERTY(Platform::String ^, EquationButtonContentIndex);
|
DEPENDENCY_PROPERTY(Platform::String ^, EquationButtonContentIndex);
|
||||||
|
DEPENDENCY_PROPERTY(Platform::String ^, MathEquation);
|
||||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, HasError);
|
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, HasError);
|
||||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsAddEquationMode);
|
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsAddEquationMode);
|
||||||
|
|
||||||
@ -35,7 +29,7 @@ namespace CalculatorApp
|
|||||||
|
|
||||||
event Windows::UI::Xaml::RoutedEventHandler ^ RemoveButtonClicked;
|
event Windows::UI::Xaml::RoutedEventHandler ^ RemoveButtonClicked;
|
||||||
event Windows::UI::Xaml::RoutedEventHandler ^ KeyGraphFeaturesButtonClicked;
|
event Windows::UI::Xaml::RoutedEventHandler ^ KeyGraphFeaturesButtonClicked;
|
||||||
event Windows::Foundation::EventHandler<EquationSubmissionSource> ^ EquationSubmitted;
|
event Windows::Foundation::EventHandler<MathRichEditBoxSubmission ^> ^ EquationSubmitted;
|
||||||
event Windows::UI::Xaml::RoutedEventHandler ^ EquationButtonClicked;
|
event Windows::UI::Xaml::RoutedEventHandler ^ EquationButtonClicked;
|
||||||
|
|
||||||
Platform::String ^ GetEquationText();
|
Platform::String ^ GetEquationText();
|
||||||
@ -48,8 +42,6 @@ namespace CalculatorApp
|
|||||||
virtual void OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
virtual void OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||||
virtual void OnPointerCanceled(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
virtual void OnPointerCanceled(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||||
virtual void OnPointerCaptureLost(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
virtual void OnPointerCaptureLost(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||||
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
|
|
||||||
virtual void OnLostFocus(Windows::UI::Xaml::RoutedEventArgs ^ e) override;
|
|
||||||
void OnIsAddEquationModePropertyChanged(bool oldValue, bool newValue);
|
void OnIsAddEquationModePropertyChanged(bool oldValue, bool newValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -59,7 +51,6 @@ namespace CalculatorApp
|
|||||||
|
|
||||||
void OnRichEditBoxGotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void OnRichEditBoxGotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void OnRichEditBoxLostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void OnRichEditBoxLostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void OnRichEditBoxTextChanged(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
|
||||||
|
|
||||||
void OnDeleteButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void OnDeleteButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
void OnEquationButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void OnEquationButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
@ -89,7 +80,7 @@ namespace CalculatorApp
|
|||||||
|
|
||||||
bool m_isPointerOver;
|
bool m_isPointerOver;
|
||||||
bool m_isColorChooserFlyoutOpen;
|
bool m_isColorChooserFlyoutOpen;
|
||||||
EquationSubmissionSource m_sourceSubmission;
|
void OnEquationSubmitted(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxSubmission ^ args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ using namespace Windows::ApplicationModel;
|
|||||||
using namespace Windows::UI::Xaml;
|
using namespace Windows::UI::Xaml;
|
||||||
using namespace Windows::UI::Xaml::Controls;
|
using namespace Windows::UI::Xaml::Controls;
|
||||||
using namespace Windows::Foundation::Collections;
|
using namespace Windows::Foundation::Collections;
|
||||||
|
using namespace Windows::System;
|
||||||
|
|
||||||
DEPENDENCY_PROPERTY_INITIALIZATION(MathRichEditBox, MathText);
|
DEPENDENCY_PROPERTY_INITIALIZATION(MathRichEditBox, MathText);
|
||||||
|
|
||||||
@ -75,6 +76,9 @@ MathRichEditBox::MathRichEditBox()
|
|||||||
{
|
{
|
||||||
throw Exception::CreateException(hr);
|
throw Exception::CreateException(hr);
|
||||||
}
|
}
|
||||||
|
this->LosingFocus += ref new Windows::Foundation::TypedEventHandler<Windows::UI::Xaml::UIElement ^, Windows::UI::Xaml::Input::LosingFocusEventArgs ^>(
|
||||||
|
this, &CalculatorApp::Controls::MathRichEditBox::OnLosingFocus);
|
||||||
|
this->KeyUp += ref new Windows::UI::Xaml::Input::KeyEventHandler(this, &CalculatorApp::Controls::MathRichEditBox::OnKeyUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
String ^ MathRichEditBox::GetMathTextProperty()
|
String ^ MathRichEditBox::GetMathTextProperty()
|
||||||
@ -111,4 +115,41 @@ void MathRichEditBox::SetMathTextProperty(String ^ newValue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->IsReadOnly = readOnlyState;
|
this->IsReadOnly = readOnlyState;
|
||||||
|
SetValue(MathTextProperty, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CalculatorApp::Controls::MathRichEditBox::OnLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args)
|
||||||
|
{
|
||||||
|
auto newVal = GetMathTextProperty();
|
||||||
|
if (MathText != newVal)
|
||||||
|
{
|
||||||
|
SetValue(MathTextProperty, newVal);
|
||||||
|
EquationSubmitted(this, ref new MathRichEditBoxSubmission(true, EquationSubmissionSource::FOCUS_LOST));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EquationSubmitted(this, ref new MathRichEditBoxSubmission(false, EquationSubmissionSource::FOCUS_LOST));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CalculatorApp::Controls::MathRichEditBox::OnKeyUp(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e)
|
||||||
|
{
|
||||||
|
if (e->Key == VirtualKey::Enter)
|
||||||
|
{
|
||||||
|
auto newVal = GetMathTextProperty();
|
||||||
|
if (MathText != newVal)
|
||||||
|
{
|
||||||
|
SetValue(MathTextProperty, newVal);
|
||||||
|
EquationSubmitted(this, ref new MathRichEditBoxSubmission(true, EquationSubmissionSource::ENTER_KEY));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EquationSubmitted(this, ref new MathRichEditBoxSubmission(true, EquationSubmissionSource::ENTER_KEY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MathRichEditBox::OnMathTextPropertyChanged(Platform::String ^ oldValue, Platform::String ^ newValue)
|
||||||
|
{
|
||||||
|
SetMathTextProperty(newValue);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,27 @@ namespace CalculatorApp
|
|||||||
{
|
{
|
||||||
namespace Controls
|
namespace Controls
|
||||||
{
|
{
|
||||||
|
public
|
||||||
|
enum class EquationSubmissionSource
|
||||||
|
{
|
||||||
|
FOCUS_LOST,
|
||||||
|
ENTER_KEY,
|
||||||
|
};
|
||||||
|
|
||||||
|
public
|
||||||
|
ref class MathRichEditBoxSubmission sealed
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PROPERTY_R(bool, HasTextChanged);
|
||||||
|
PROPERTY_R(EquationSubmissionSource, Source);
|
||||||
|
public:
|
||||||
|
MathRichEditBoxSubmission(bool hasTextChanged, EquationSubmissionSource source)
|
||||||
|
: m_HasTextChanged(hasTextChanged)
|
||||||
|
, m_Source(source)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public
|
public
|
||||||
ref class MathRichEditBox sealed : Windows::UI::Xaml::Controls::RichEditBox
|
ref class MathRichEditBox sealed : Windows::UI::Xaml::Controls::RichEditBox
|
||||||
{
|
{
|
||||||
@ -15,35 +36,17 @@ namespace CalculatorApp
|
|||||||
MathRichEditBox();
|
MathRichEditBox();
|
||||||
|
|
||||||
DEPENDENCY_PROPERTY_OWNER(MathRichEditBox);
|
DEPENDENCY_PROPERTY_OWNER(MathRichEditBox);
|
||||||
|
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Platform::String ^, MathText, L"");
|
||||||
|
|
||||||
static property Windows::UI::Xaml::DependencyProperty ^ MathTextProperty
|
event Windows::Foundation::EventHandler<MathRichEditBoxSubmission^> ^ EquationSubmitted;
|
||||||
{
|
void OnMathTextPropertyChanged(Platform::String ^ oldValue, Platform::String ^ newValue);
|
||||||
Windows::UI::Xaml::DependencyProperty ^ get() {
|
|
||||||
return s_MathTextProperty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
property Platform::String ^ MathText
|
|
||||||
{
|
|
||||||
Platform::String ^ get()
|
|
||||||
{
|
|
||||||
return GetMathTextProperty();
|
|
||||||
}
|
|
||||||
void set(Platform::String^ value)
|
|
||||||
{
|
|
||||||
SetMathTextProperty(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
private:
|
||||||
Platform::String ^ GetMathTextProperty();
|
Platform::String ^ GetMathTextProperty();
|
||||||
void SetMathTextProperty(Platform::String ^ newValue);
|
void SetMathTextProperty(Platform::String ^ newValue);
|
||||||
|
|
||||||
static Windows::UI::Xaml::DependencyProperty ^ s_MathTextProperty;
|
void OnLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args);
|
||||||
static Windows::UI::Xaml::DependencyProperty ^ InitializeMathTextProperty()
|
void OnKeyUp(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e);
|
||||||
{
|
|
||||||
return Utils::RegisterDependencyProperty<DependencyPropertiesOwner, Platform::String ^>(L"MathText");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,6 +243,7 @@
|
|||||||
KeyGraphFeaturesButtonClicked="EquationTextBox_KeyGraphFeaturesButtonClicked"
|
KeyGraphFeaturesButtonClicked="EquationTextBox_KeyGraphFeaturesButtonClicked"
|
||||||
Loaded="InputTextBox_Loaded"
|
Loaded="InputTextBox_Loaded"
|
||||||
LostFocus="InputTextBox_LostFocus"
|
LostFocus="InputTextBox_LostFocus"
|
||||||
|
MathEquation="{x:Bind Expression, Mode=TwoWay}"
|
||||||
RemoveButtonClicked="EquationTextBox_RemoveButtonClicked">
|
RemoveButtonClicked="EquationTextBox_RemoveButtonClicked">
|
||||||
<controls:EquationTextBox.ColorChooserFlyout>
|
<controls:EquationTextBox.ColorChooserFlyout>
|
||||||
<Flyout x:Name="ColorChooserFlyout"
|
<Flyout x:Name="ColorChooserFlyout"
|
||||||
|
@ -84,7 +84,7 @@ void EquationInputArea::InputTextBox_LostFocus(Object ^ sender, RoutedEventArgs
|
|||||||
KeyboardShortcutManager::HonorShortcuts(true);
|
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);
|
auto tb = static_cast<EquationTextBox ^>(sender);
|
||||||
if (tb == nullptr)
|
if (tb == nullptr)
|
||||||
@ -97,16 +97,8 @@ void EquationInputArea::InputTextBox_Submitted(Object ^ sender, EquationSubmissi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto expressionText = tb->GetEquationText();
|
if (submission->Source == EquationSubmissionSource::ENTER_KEY ||
|
||||||
if (source == EquationSubmissionSource::FOCUS_LOST && eq->Expression == expressionText)
|
(submission->Source == EquationSubmissionSource::FOCUS_LOST && submission->HasTextChanged && eq->Expression != nullptr && eq->Expression->Length() > 0))
|
||||||
{
|
|
||||||
// The expression didn't change.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
eq->Expression = expressionText;
|
|
||||||
|
|
||||||
if (source == EquationSubmissionSource::ENTER_KEY || eq->Expression != nullptr && eq->Expression->Length() > 0)
|
|
||||||
{
|
{
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
if (Equations->IndexOf(eq, &index))
|
if (Equations->IndexOf(eq, &index))
|
||||||
@ -180,13 +172,6 @@ void EquationInputArea::EquationTextBox_RemoveButtonClicked(Object ^ sender, Rou
|
|||||||
void EquationInputArea::EquationTextBox_KeyGraphFeaturesButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationInputArea::EquationTextBox_KeyGraphFeaturesButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
auto tb = static_cast<EquationTextBox ^>(sender);
|
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);
|
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
|
||||||
KeyGraphFeaturesRequested(this, eq);
|
KeyGraphFeaturesRequested(this, eq);
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,9 @@ namespace CalculatorApp
|
|||||||
|
|
||||||
void AddNewEquation();
|
void AddNewEquation();
|
||||||
|
|
||||||
void InputTextBox_GotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs^ 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_LostFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
void InputTextBox_Submitted(Platform::Object ^ sender, CalculatorApp::Controls::EquationSubmissionSource e);
|
void InputTextBox_Submitted(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxSubmission ^ e);
|
||||||
|
|
||||||
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^ sender, Platform::Object ^ args);
|
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^ sender, Platform::Object ^ args);
|
||||||
void ReloadAvailableColors(bool isHighContrast);
|
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)
|
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 +=
|
m_activeTracingKeyUpToken = Window::Current->CoreWindow->KeyUp +=
|
||||||
ref new Windows::Foundation::TypedEventHandler<Windows::UI::Core::CoreWindow ^, Windows::UI::Core::KeyEventArgs ^>(
|
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;
|
ShiftButton->IsChecked = false;
|
||||||
SetOperatorRowVisibility();
|
SetOperatorRowVisibility();
|
||||||
ShiftButton->Focus(::FocusState::Programmatic);
|
FocusManager::TryFocusAsync(ShiftButton, ::FocusState::Programmatic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphingNumPad::TrigFlyoutShift_Toggle(_In_ Platform::Object ^ /*sender*/, _In_ Windows::UI::Xaml::RoutedEventArgs ^ /*e*/)
|
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)
|
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)
|
if (m_converter != nullptr && m_converter->Visibility == ::Visibility::Visible)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user