mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-21 05:43:10 -07:00
Fix crash when using "C" key to clear equation (#1152)
* Fix two pane crash on closing window * clearcrash
This commit is contained in:
parent
a6ac3bbeae
commit
07108af967
1 changed files with 11 additions and 3 deletions
|
@ -22,7 +22,8 @@ using namespace Windows::UI::Xaml::Input;
|
||||||
using namespace Windows::UI::Xaml::Media;
|
using namespace Windows::UI::Xaml::Media;
|
||||||
using namespace Windows::UI::Xaml::Navigation;
|
using namespace Windows::UI::Xaml::Navigation;
|
||||||
|
|
||||||
// Dictionary of the enum of the button clicked mapped to an object with the string to enter into the rich edit, and the start and end of the selection after text has been entered.
|
// Dictionary of the enum of the button clicked mapped to an object with the string to enter into the rich edit, and the start and end of the selection after
|
||||||
|
// text has been entered.
|
||||||
static const std::unordered_map<NumbersAndOperatorsEnum, std::tuple<Platform::String ^, int, int>> buttonOutput = {
|
static const std::unordered_map<NumbersAndOperatorsEnum, std::tuple<Platform::String ^, int, int>> buttonOutput = {
|
||||||
{ NumbersAndOperatorsEnum::Sin, { L"sin()", 4, 0 } },
|
{ NumbersAndOperatorsEnum::Sin, { L"sin()", 4, 0 } },
|
||||||
{ NumbersAndOperatorsEnum::Cos, { L"cos()", 4, 0 } },
|
{ NumbersAndOperatorsEnum::Cos, { L"cos()", 4, 0 } },
|
||||||
|
@ -224,8 +225,15 @@ void GraphingNumPad::ClearButton_Clicked(Platform::Object ^ /*sender*/, RoutedEv
|
||||||
auto mathRichEdit = GetActiveRichEdit();
|
auto mathRichEdit = GetActiveRichEdit();
|
||||||
if (mathRichEdit != nullptr)
|
if (mathRichEdit != nullptr)
|
||||||
{
|
{
|
||||||
mathRichEdit->MathText = L"<math xmlns=\"http://www.w3.org/1998/Math/MathML\"></math>";
|
String ^ text;
|
||||||
mathRichEdit->SubmitEquation(CalculatorApp::Controls::EquationSubmissionSource::PROGRAMMATIC);
|
mathRichEdit->TextDocument->GetText(Windows::UI::Text::TextGetOptions::NoHidden, &text);
|
||||||
|
|
||||||
|
if (!text->IsEmpty())
|
||||||
|
{
|
||||||
|
mathRichEdit->MathText = L"<math xmlns=\"http://www.w3.org/1998/Math/MathML\"></math>";
|
||||||
|
mathRichEdit->SubmitEquation(CalculatorApp::Controls::EquationSubmissionSource::PROGRAMMATIC);
|
||||||
|
}
|
||||||
|
|
||||||
TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::Clear, CalculatorApp::Common::ViewMode::Graphing);
|
TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::Clear, CalculatorApp::Common::ViewMode::Graphing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue