Skip to content

Commit

Permalink
add UIA properties
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Oct 3, 2022
1 parent bf6f0ff commit 9fd73c7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/types/TermControlUiaProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,56 @@ HRESULT TermControlUiaProvider::RuntimeClassInitialize(_In_ ::Microsoft::Console
return S_OK;
}

// Implementation of IRawElementProviderSimple::get_PropertyValue.
// Gets custom properties.
IFACEMETHODIMP TermControlUiaProvider::GetPropertyValue(_In_ PROPERTYID propertyId,
_Out_ VARIANT* pVariant) noexcept
{
pVariant->vt = VT_EMPTY;

// Returning the default will leave the property as the default
// so we only really need to touch it for the properties we want to implement
if (propertyId == UIA_ClassNamePropertyId)
{
pVariant->bstrVal = SysAllocString(L"TermControl");
if (pVariant->bstrVal != nullptr)
{
pVariant->vt = VT_BSTR;
}
}
else if (propertyId == UIA_ControlTypePropertyId)
{
pVariant->vt = VT_I4;
pVariant->lVal = UIA_TextControlTypeId;
}
else if (propertyId == UIA_LocalizedControlTypePropertyId)
{
// TODO: we should use RS_(L"TerminalControl_ControlType"),
// but that's exposed/defined in the TermControl project
pVariant->bstrVal = SysAllocString(L"terminal");
if (pVariant->bstrVal != nullptr)
{
pVariant->vt = VT_BSTR;
}
}
else if (propertyId == UIA_OrientationPropertyId)
{
pVariant->vt = VT_I4;
pVariant->lVal = OrientationType_Vertical;
}
else if (propertyId == UIA_LiveSettingPropertyId)
{
pVariant->vt = VT_I4;
pVariant->lVal = LiveSetting::Polite;
}
else
{
// fall back to the shared implementation
ScreenInfoUiaProviderBase::GetPropertyValue(propertyId, pVariant);
}
return S_OK;
}

IFACEMETHODIMP TermControlUiaProvider::Navigate(_In_ NavigateDirection direction,
_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) noexcept
{
Expand Down
4 changes: 4 additions & 0 deletions src/types/TermControlUiaProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ namespace Microsoft::Terminal
HRESULT RuntimeClassInitialize(_In_ ::Microsoft::Console::Types::IUiaData* const uiaData,
_In_ ::Microsoft::Console::Types::IControlAccessibilityInfo* controlInfo) noexcept;

// IRawElementProviderSimple methods
IFACEMETHODIMP GetPropertyValue(_In_ PROPERTYID idProp,
_Out_ VARIANT* pVariant) noexcept override;

// IRawElementProviderFragment methods
IFACEMETHODIMP Navigate(_In_ NavigateDirection direction,
_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) noexcept override;
Expand Down

0 comments on commit 9fd73c7

Please sign in to comment.