Fix focus for EquationTextBox (#787)
This commit is contained in:
parent
442ed6a861
commit
afc1b2146c
@ -142,7 +142,7 @@ void EquationTextBox::OnRichEditBoxTextChanged(Object ^ sender, RoutedEventArgs
|
|||||||
|
|
||||||
void EquationTextBox::OnRichEditBoxGotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationTextBox::OnRichEditBoxGotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
m_isFocused = true;
|
m_HasFocus = true;
|
||||||
UpdateCommonVisualState();
|
UpdateCommonVisualState();
|
||||||
UpdateDeleteButtonVisualState();
|
UpdateDeleteButtonVisualState();
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ void EquationTextBox::OnRichEditBoxLostFocus(Object ^ sender, RoutedEventArgs ^
|
|||||||
{
|
{
|
||||||
if (!m_richEditBox->ContextFlyout->IsOpen)
|
if (!m_richEditBox->ContextFlyout->IsOpen)
|
||||||
{
|
{
|
||||||
m_isFocused = false;
|
m_HasFocus = false;
|
||||||
}
|
}
|
||||||
UpdateCommonVisualState();
|
UpdateCommonVisualState();
|
||||||
UpdateDeleteButtonVisualState();
|
UpdateDeleteButtonVisualState();
|
||||||
@ -222,7 +222,7 @@ void EquationTextBox::UpdateCommonVisualState()
|
|||||||
{
|
{
|
||||||
String ^ state = "Normal";
|
String ^ state = "Normal";
|
||||||
|
|
||||||
if (m_isFocused)
|
if (m_HasFocus)
|
||||||
{
|
{
|
||||||
state = "Focused";
|
state = "Focused";
|
||||||
}
|
}
|
||||||
@ -271,5 +271,5 @@ bool EquationTextBox::ShouldDeleteButtonBeVisible()
|
|||||||
{
|
{
|
||||||
text = m_richEditBox->MathText;
|
text = m_richEditBox->MathText;
|
||||||
}
|
}
|
||||||
return (!text->IsEmpty() && m_isFocused);
|
return (!text->IsEmpty() && m_HasFocus);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ 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);
|
||||||
|
|
||||||
|
PROPERTY_R(bool, HasFocus);
|
||||||
|
|
||||||
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::UI::Xaml::RoutedEventHandler ^ EquationSubmitted;
|
event Windows::UI::Xaml::RoutedEventHandler ^ EquationSubmitted;
|
||||||
@ -64,7 +66,6 @@ namespace CalculatorApp
|
|||||||
Windows::UI::Xaml::Controls::Button^ m_functionButton;
|
Windows::UI::Xaml::Controls::Button^ m_functionButton;
|
||||||
Windows::UI::Xaml::Controls::Primitives::ToggleButton^ m_colorChooserButton;
|
Windows::UI::Xaml::Controls::Primitives::ToggleButton^ m_colorChooserButton;
|
||||||
|
|
||||||
bool m_isFocused;
|
|
||||||
bool m_isPointerOver;
|
bool m_isPointerOver;
|
||||||
bool m_isColorChooserFlyoutOpen;
|
bool m_isColorChooserFlyoutOpen;
|
||||||
};
|
};
|
||||||
|
@ -87,8 +87,12 @@ void EquationInputArea::InputTextBox_Submitted(Object ^ sender, RoutedEventArgs
|
|||||||
auto tb = static_cast<EquationTextBox ^>(sender);
|
auto tb = static_cast<EquationTextBox ^>(sender);
|
||||||
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
|
auto eq = static_cast<EquationViewModel ^>(tb->DataContext);
|
||||||
eq->Expression = tb->GetEquationText();
|
eq->Expression = tb->GetEquationText();
|
||||||
|
|
||||||
|
if (tb->HasFocus)
|
||||||
|
{
|
||||||
FocusManager::TryMoveFocus(::FocusNavigationDirection::Left);
|
FocusManager::TryMoveFocus(::FocusNavigationDirection::Left);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EquationInputArea::EquationTextBox_RemoveButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
void EquationInputArea::EquationTextBox_RemoveButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user