Adjustments to ghost textbox (#924)
* adjustments * delete extra visual states * Fix hover bug * Fix a few more bugs * Fix high contrast crash
This commit is contained in:
committed by
Stephanie Anderl
parent
ab2ad8cdee
commit
240792a775
@@ -51,9 +51,9 @@ void EquationTextBox::OnApplyTemplate()
|
||||
{
|
||||
m_richEditBox->GotFocus += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxGotFocus);
|
||||
m_richEditBox->LostFocus += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxLostFocus);
|
||||
m_richEditBox->TextChanged += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditTextChanged);
|
||||
m_richEditBox->SelectionFlyout = nullptr;
|
||||
m_richEditBox->EquationSubmitted +=
|
||||
ref new EventHandler<MathRichEditBoxSubmission ^>(this, &EquationTextBox::OnEquationSubmitted);
|
||||
m_richEditBox->EquationSubmitted += ref new EventHandler<MathRichEditBoxSubmission ^>(this, &EquationTextBox::OnEquationSubmitted);
|
||||
m_richEditBox->FormatRequest += ref new EventHandler<MathRichEditBoxFormatRequest ^>(this, &EquationTextBox::OnEquationFormatRequested);
|
||||
}
|
||||
|
||||
@@ -160,6 +160,12 @@ void EquationTextBox::OnColorFlyoutClosed(Object ^ sender, Object ^ e)
|
||||
UpdateCommonVisualState();
|
||||
}
|
||||
|
||||
void EquationTextBox::OnRichEditTextChanged(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
UpdateCommonVisualState();
|
||||
UpdateButtonsVisualState();
|
||||
}
|
||||
|
||||
void EquationTextBox::OnRichEditBoxGotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
m_HasFocus = true;
|
||||
@@ -182,7 +188,7 @@ void EquationTextBox::OnDeleteButtonClicked(Object ^ sender, RoutedEventArgs ^ e
|
||||
{
|
||||
if (m_richEditBox != nullptr)
|
||||
{
|
||||
m_richEditBox->MathText = L"";
|
||||
m_richEditBox->TextDocument->SetText(::TextSetOptions::None, "");
|
||||
if (m_functionButton)
|
||||
{
|
||||
m_functionButton->IsEnabled = false;
|
||||
@@ -248,14 +254,14 @@ void EquationTextBox::UpdateButtonsVisualState()
|
||||
{
|
||||
String ^ state;
|
||||
|
||||
if (IsAddEquationMode)
|
||||
{
|
||||
state = "ButtonHideRemove";
|
||||
}
|
||||
else if (RichEditHasContent())
|
||||
if (m_HasFocus && RichEditHasContent())
|
||||
{
|
||||
state = "ButtonVisible";
|
||||
}
|
||||
else if (IsAddEquationMode)
|
||||
{
|
||||
state = "ButtonHideRemove";
|
||||
}
|
||||
else
|
||||
{
|
||||
state = "ButtonCollapsed";
|
||||
@@ -272,6 +278,10 @@ void EquationTextBox::UpdateCommonVisualState()
|
||||
{
|
||||
state = "FocusedError";
|
||||
}
|
||||
else if (IsAddEquationMode && ((m_HasFocus || m_isPointerOver) && !RichEditHasContent()))
|
||||
{
|
||||
state = "AddEquation";
|
||||
}
|
||||
else if (m_HasFocus)
|
||||
{
|
||||
state = "Focused";
|
||||
@@ -338,21 +348,21 @@ bool EquationTextBox::RichEditHasContent()
|
||||
|
||||
if (m_richEditBox != nullptr)
|
||||
{
|
||||
text = m_richEditBox->MathText;
|
||||
m_richEditBox->TextDocument->GetText(Windows::UI::Text::TextGetOptions::NoHidden, &text);
|
||||
}
|
||||
return !text->IsEmpty() && m_HasFocus;
|
||||
return !text->IsEmpty();
|
||||
}
|
||||
|
||||
void EquationTextBox::OnRichEditMenuOpening(Object ^ /*sender*/, Object ^ /*args*/)
|
||||
{
|
||||
if (m_kgfEquationMenuItem != nullptr)
|
||||
{
|
||||
m_kgfEquationMenuItem->IsEnabled = RichEditHasContent();
|
||||
m_kgfEquationMenuItem->IsEnabled = m_HasFocus && RichEditHasContent();
|
||||
}
|
||||
|
||||
if (m_colorChooserMenuItem != nullptr)
|
||||
{
|
||||
m_colorChooserMenuItem->IsEnabled = !HasError;
|
||||
m_colorChooserMenuItem->IsEnabled = !HasError && !IsAddEquationMode;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -52,6 +52,7 @@ namespace CalculatorApp
|
||||
|
||||
void OnRichEditBoxGotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnRichEditBoxLostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnRichEditTextChanged(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);
|
||||
|
Reference in New Issue
Block a user