Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply AutoProps to TextBox settings in SUI #14178

Merged
4 commits merged into from
Nov 4, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 23 additions & 20 deletions src/cascadia/TerminalSettingsEditor/SettingContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DependencyObject> base(2, nullptr);
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
if (const auto& child{ GetTemplateChild(L"Expander") })
{
if (const auto& expander{ child.try_as<Microsoft::UI::Xaml::Controls::Expander>() })
{
base = child;
base.push_back(child);
}
}
else if (const auto& content{ Content() })
if (const auto& content{ Content() })
{
if (const auto& obj{ content.try_as<DependencyObject>() })
{
base = obj;
base.push_back(obj);
}
}

if (base)
for (auto obj : base)
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
{
// apply header as name (automation property)
if (const auto& header{ Header() })
if (obj)
{
if (const auto headerText{ header.try_as<hstring>() })
// apply header as name (automation property)
if (const auto& header{ Header() })
{
Automation::AutomationProperties::SetName(base, *headerText);
if (const auto headerText{ header.try_as<hstring>() })
{
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"");
}
}
}

Expand Down