Skip to content

Commit

Permalink
Enable text search on combo boxes (#9206)
Browse files Browse the repository at this point in the history
`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
microsoft/microsoft-ui-xaml#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.
  • Loading branch information
carlos-zamora committed Feb 19, 2021
1 parent 654c0cc commit 2c22b68
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/actions/spelling/dictionary/apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ IObject
IPackage
IPeasant
IStorage
IStringable
ITab
ITaskbar
LCID
Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/TerminalSettingsEditor/EnumEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsEditor/EnumEntry.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/TerminalSettingsModel/ColorScheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsModel/ColorScheme.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/cascadia/TerminalSettingsModel/Profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsModel/Profile.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 2c22b68

Please sign in to comment.