Add context menu to rich edit to allow for keyboard support (#854)

* Add context menu to rich edit to allow for keyboard support

* Update src/Calculator/Controls/EquationTextBox.cpp

Co-Authored-By: Pepe Rivera <joseartrivera@gmail.com>

* Check for focus before triggering submit
This commit is contained in:
Eric Wong
2019-12-09 13:18:06 -08:00
committed by GitHub
parent c6d3132ad4
commit 4bb5c39e34
5 changed files with 104 additions and 16 deletions

View File

@@ -36,7 +36,7 @@ EquationInputArea::EquationInputArea()
ref new TypedEventHandler<AccessibilitySettings ^, Object ^>(this, &EquationInputArea::OnHighContrastChanged);
ReloadAvailableColors(m_accessibilitySettings->HighContrast);
InitializeComponent();
}
@@ -88,7 +88,12 @@ void EquationInputArea::InputTextBox_Submitted(Object ^ sender, RoutedEventArgs
{
auto tb = static_cast<EquationTextBox ^>(sender);
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
eq->Expression = tb->GetEquationText();
// eq can be null if the equation has been removed
if (eq != nullptr)
{
eq->Expression = tb->GetEquationText();
}
if (tb->HasFocus)
{
@@ -115,8 +120,16 @@ 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, e);
}
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
EquationVM = eq;
KeyGraphFeaturesRequested(EquationVM, ref new RoutedEventArgs());
}