From 9b57cd3962ac2eb765d50a61bf0a8f9dd1470d06 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Mon, 10 Oct 2022 16:04:39 -0700 Subject: [PATCH 1/2] Apply AutoProps to TextBox settings in SUI --- .../SettingContainer.cpp | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp index 50a06792fef..54c5728e758 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp @@ -133,43 +133,46 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _UpdateOverrideSystem(); // Get the correct base to apply automation properties to - DependencyObject base{ nullptr }; + std::vector base(2, nullptr); if (const auto& child{ GetTemplateChild(L"Expander") }) { if (const auto& expander{ child.try_as() }) { - base = child; + base.push_back(child); } } - else if (const auto& content{ Content() }) + if (const auto& content{ Content() }) { if (const auto& obj{ content.try_as() }) { - base = obj; + base.push_back(obj); } } - if (base) + for (auto obj : base) { - // apply header as name (automation property) - if (const auto& header{ Header() }) + if (obj) { - if (const auto headerText{ header.try_as() }) + // apply header as name (automation property) + if (const auto& header{ Header() }) { - Automation::AutomationProperties::SetName(base, *headerText); + if (const auto headerText{ header.try_as() }) + { + Automation::AutomationProperties::SetName(obj, *headerText); + } } - } - // apply help text as tooltip and full description (automation property) - if (const auto& helpText{ HelpText() }; !helpText.empty()) - { - Controls::ToolTipService::SetToolTip(base, box_value(helpText)); - Automation::AutomationProperties::SetFullDescription(base, helpText); - } - else - { - Controls::ToolTipService::SetToolTip(base, nullptr); - Automation::AutomationProperties::SetFullDescription(base, L""); + // apply help text as tooltip and full description (automation property) + if (const auto& helpText{ HelpText() }; !helpText.empty()) + { + Controls::ToolTipService::SetToolTip(obj, box_value(helpText)); + Automation::AutomationProperties::SetFullDescription(obj, helpText); + } + else + { + Controls::ToolTipService::SetToolTip(obj, nullptr); + Automation::AutomationProperties::SetFullDescription(obj, L""); + } } } From 99ceaf5accb700117c72f65a28271ff38f06861e Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Wed, 12 Oct 2022 10:52:10 -0700 Subject: [PATCH 2/2] apply feedback; don't apply AP to panels --- .../SettingContainer.cpp | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp index 54c5728e758..63bd045cc60 100644 --- a/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp +++ b/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp @@ -133,7 +133,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _UpdateOverrideSystem(); // Get the correct base to apply automation properties to - std::vector base(2, nullptr); + std::vector base; + base.reserve(2); if (const auto& child{ GetTemplateChild(L"Expander") }) { if (const auto& expander{ child.try_as() }) @@ -143,36 +144,35 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } if (const auto& content{ Content() }) { - if (const auto& obj{ content.try_as() }) + const auto& panel{ content.try_as() }; + const auto& obj{ content.try_as() }; + if (!panel && obj) { base.push_back(obj); } } - for (auto obj : base) + for (const auto& obj : base) { - if (obj) + // apply header as name (automation property) + if (const auto& header{ Header() }) { - // apply header as name (automation property) - if (const auto& header{ Header() }) + if (const auto headerText{ header.try_as() }) { - if (const auto headerText{ header.try_as() }) - { - Automation::AutomationProperties::SetName(obj, *headerText); - } + Automation::AutomationProperties::SetName(obj, *headerText); } + } - // apply help text as tooltip and full description (automation property) - if (const auto& helpText{ HelpText() }; !helpText.empty()) - { - Controls::ToolTipService::SetToolTip(obj, box_value(helpText)); - Automation::AutomationProperties::SetFullDescription(obj, helpText); - } - else - { - Controls::ToolTipService::SetToolTip(obj, nullptr); - Automation::AutomationProperties::SetFullDescription(obj, L""); - } + // apply help text as tooltip and full description (automation property) + if (const auto& helpText{ HelpText() }; !helpText.empty()) + { + Controls::ToolTipService::SetToolTip(obj, box_value(helpText)); + Automation::AutomationProperties::SetFullDescription(obj, helpText); + } + else + { + Controls::ToolTipService::SetToolTip(obj, nullptr); + Automation::AutomationProperties::SetFullDescription(obj, L""); } }