Enable text search on combo boxes (#9206)

`ComboBox` has a text search function that allows users to type letters, and the `ComboBoxItem` starting with those letters is shown. In order to enable this functionality, the underlying items must be `IStringable`. This exposes a `ToString()` function and fixes all of our issues.

This PR adds the `IStringable` interface to `ColorScheme`, `Profile`, and `EnumEntry`.

## References
#6800 - Settings UI Epic
#8768 - Keyboard Navigation
https://github.com/microsoft/microsoft-ui-xaml/issues/4182 - discussion with WinUI about how to overcome this issue

## Validation Steps Performed
Tested...
- Launch > Default Profile
- Color Schemes > Name
- Profile > Appearance > Color scheme
- Profile > Appearance > Font weight

Also tested radio buttons, but those still don't work, unfortunately. Looks like they don't have the same underlying mechanism.
This commit is contained in:
Carlos Zamora 2021-02-19 10:11:07 -08:00 committed by GitHub
parent 654c0cc286
commit 2c22b68e15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 3 deletions

View file

@ -41,6 +41,7 @@ IObject
IPackage
IPeasant
IStorage
IStringable
ITab
ITaskbar
LCID

View file

@ -46,6 +46,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_EnumName{ enumName },
_EnumValue{ enumValue } {}
hstring ToString()
{
return EnumName();
}
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
OBSERVABLE_GETSET_PROPERTY(winrt::hstring, EnumName, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(winrt::Windows::Foundation::IInspectable, EnumValue, _PropertyChangedHandlers);

View file

@ -3,7 +3,7 @@
namespace Microsoft.Terminal.Settings.Editor
{
[default_interface] runtimeclass EnumEntry : Windows.UI.Xaml.Data.INotifyPropertyChanged
[default_interface] runtimeclass EnumEntry : Windows.UI.Xaml.Data.INotifyPropertyChanged, Windows.Foundation.IStringable
{
String EnumName { get; };
IInspectable EnumValue { get; };

View file

@ -37,6 +37,11 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
ColorScheme(hstring name, COLORREF defaultFg, COLORREF defaultBg, COLORREF cursorColor);
com_ptr<ColorScheme> Copy() const;
hstring ToString()
{
return Name();
}
static com_ptr<ColorScheme> FromJson(const Json::Value& json);
bool ShouldBeLayered(const Json::Value& json) const;
void LayerJson(const Json::Value& json);

View file

@ -3,7 +3,7 @@
namespace Microsoft.Terminal.Settings.Model
{
[default_interface] runtimeclass ColorScheme {
[default_interface] runtimeclass ColorScheme : Windows.Foundation.IStringable {
ColorScheme(String name);
String Name;

View file

@ -47,6 +47,12 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
public:
Profile();
Profile(guid guid);
hstring ToString()
{
return Name();
}
static com_ptr<Profile> CloneInheritanceGraph(com_ptr<Profile> oldProfile, com_ptr<Profile> newProfile, std::unordered_map<void*, com_ptr<Profile>>& visited);
static com_ptr<Profile> CopySettings(com_ptr<Profile> source);

View file

@ -31,7 +31,7 @@ namespace Microsoft.Terminal.Settings.Model
Vertical_Bottom = 0x20
};
[default_interface] runtimeclass Profile {
[default_interface] runtimeclass Profile : Windows.Foundation.IStringable {
Profile();
Profile(Guid guid);