-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support ScrollView keyboardDismissMode #3665
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
Conversation
| void SIPEventHandler::AttachView(XamlView xamlView, bool fireKeyboardEvents) { | ||
| m_fireKeyboradEvents = fireKeyboardEvents; | ||
|
|
||
| if (Is19H1OrHigher()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is19H1OrHigher [](start = 6, length = 14)
Suggest you use if (auto uie = try_aswinrt::IUIElement10().
It's possible we don't need to make code change in the future when integrate with winui3. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is there mainly for CoreInputView::GetForUIContext, last heard there is no plan to bring that down level yet.. We can always reevaluate at later time by searching the code where we call the platform check such as Is19H1orHigher..
In reply to: 347710901 [](ancestors = 347710901)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I realized CoreInputView.TryShow/TryHide is not availiable until RS5, so more platform check is needed. And I probably need to fall back to InputPane API on earlier OS.
In reply to: 348209889 [](ancestors = 348209889,347710901)
| if (m_coreInputView) { | ||
| auto occlusions = m_coreInputView.GetCoreInputViewOcclusions(); | ||
| m_isShowing = !IsOcclusionsEmpty(occlusions); | ||
| m_occlusionsChanged_revoker = m_coreInputView.OcclusionsChanged( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OcclusionsChanged [](start = 50, length = 17)
I think this API is introduced since 16299 but we support 15063 #Resolved
| SIPEventHandler::~SIPEventHandler() { | ||
| m_occlusionsChanged_revoker = {}; | ||
| bool SIPEventHandler::TryShow() { | ||
| if (m_coreInputView == nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
== nullptr [](start = 21, length = 11)
nit: if (m_coreInputView) #Resolved
| } | ||
|
|
||
| bool SIPEventHandler::TryHide() { | ||
| if (m_coreInputView == nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_coreInputView [](start = 6, length = 15)
nit: if (m_coreInputView) #Resolved
| std::weak_ptr<IReactInstance> m_wkReactInstance; | ||
| winrt::CoreInputView::OcclusionsChanged_revoker m_occlusionsChanged_revoker; | ||
| winrt::Rect m_finalRect; | ||
| winrt::CoreInputView m_coreInputView = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
winrt::CoreInputView m_coreInputView = nullptr [](start = 2, length = 46)
prefer winrt::CoreInputView m_coreInputView{ nullptr } #Resolved
| winrt::CoreInputView::OcclusionsChanged_revoker m_occlusionsChanged_revoker; | ||
| winrt::Rect m_finalRect; | ||
| winrt::CoreInputView m_coreInputView = nullptr; | ||
| bool m_isShowing = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool m_isShowing = false [](start = 2, length = 24)
prefer bool m_isShowing{ false } #Resolved
| m_dismissKeyboardOnDrag = false; | ||
| if (propertyValue.isString()) { | ||
| m_dismissKeyboardOnDrag = (propertyValue.getString() == "on-drag"); | ||
| RegisterSIPEventsWhenNeeded(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RegisterSIPEventsWhenNeeded [](start = 8, length = 27)
Do you need to unRegisterSIPEventsWhenNeeded in else? otherwise there is a callback is never be released. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine, we tear down event registration in the destructor of keyboardEventHandler, and we release keyboardEventHandler in ~ScrollViewShadowNode.
In reply to: 348693046 [](ancestors = 348693046)
| m_isScrolling = true; | ||
|
|
||
| if (m_dismissKeyboardOnDrag) { | ||
| if (m_SIPEventHandler) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_SIPEventHandler [](start = 14, length = 17)
nit: if (m_dismissKeyboardOnDrag && m_SIPEventHandler) #Resolved
| void ScrollViewShadowNode::RegisterSIPEventsWhenNeeded() { | ||
| if (m_dismissKeyboardOnDrag) { | ||
| auto view = GetView(); | ||
| if (winrt::VisualTreeHelper::GetParent(view) != nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!= nullptr) [](start = 48, length = 12)
nit: remove !=nullptr #Resolved
|
|
||
| SIPEventHandler::~SIPEventHandler() { | ||
| m_occlusionsChanged_revoker = {}; | ||
| bool SIPEventHandler::TryShow() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TryShow [](start = 22, length = 7)
I didn't see you can TryShow, why do you need this function? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am expecting to call this function in one of the future ScrollView's API implementation. For now, I will just comment it out.
In reply to: 348697998 [](ancestors = 348697998)
| return false; | ||
| } | ||
|
|
||
| bool SIPEventHandler::TryHide() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool [](start = 0, length = 4)
I didn't see you check the result, so just return void instead of bool #Resolved
| winrt::CoreInputViewOcclusion occlusion = occlusions.GetAt(i); | ||
| if (occlusion.OcclusionKind() == winrt::CoreInputViewOcclusionKind::Docked) { | ||
| m_finalRect = winrt::RectHelper::Union(m_finalRect, occlusion.OccludingRect()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: cppwinrt supports for like this
for (auto const& item: occlusions) {
}
or
for (auto item: occlusions) {
}
I don't know if the first one will work or not #Resolved
licanhua
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
#3068
-Hook up property keyboardDismissMode in ScrollViewManager.
-When manipulation starts and if keyboardDismissMode is on-drag, issue TryHide though SIP event handler.
Microsoft Reviewers: Open in CodeFlow