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

Add InputScope Property To NumberBox #3186

Merged
merged 9 commits into from
Sep 24, 2020
Merged
14 changes: 14 additions & 0 deletions dev/NumberBox/NumberBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ NumberBox::NumberBox()
LostFocus({ this, &NumberBox::OnNumberBoxLostFocus });

SetDefaultStyleKey(this);
SetDefaultInputScope();
}

void NumberBox::SetDefaultInputScope()
{
// Sets the default value of the InputScope property.
// Note that InputScope is a class that cannot be set to a default value within the IDL.
winrt::InputScopeName inputScopeName = winrt::InputScopeName(winrt::InputScopeNameValue::Number);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we prefer using auto and const for the local variable types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a problem, should I pursue this now though or wait for potential work-arounds setting in the default style?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just did it now so hopefully we can close this. There is no response on work-arounds for the XAML bugs.

winrt::InputScope inputScope = winrt::InputScope();
inputScope.Names().Append(inputScopeName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names [](start = 15, length = 5)

I'm not that familiar with inputScope, does this mean that you can apply multiple input scopes? like you can have number and currency at the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean that you can apply multiple input scopes?
Yes, you can apply multiple name values to the same input scope.

It's certainly an interesting design decision, one which I've never understood myself. However, my assumption has always been it's for the cases where the user can switch the keyboard. It simply limits what keyboards you are allowed to switch between. You might have to reach out to the Windows team to understand the thinking here though. I don't recall ever seeing documented reasons why this is a collection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MikeHillberg do you happen to know?


static_cast<NumberBox*>(this)->SetValue(s_InputScopeProperty, ValueHelper<winrt::InputScope>::BoxValueIfNecessary(inputScope));

return;
}

// This was largely copied from Calculator's GetRegionalSettingsAwareDecimalFormatter()
Expand Down
2 changes: 2 additions & 0 deletions dev/NumberBox/NumberBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class NumberBox :

void MoveCaretToTextEnd();

void SetDefaultInputScope();

bool m_valueUpdating{ false };
bool m_textUpdating{ false };

Expand Down