Skip to content

Conversation

@ddalp
Copy link
Contributor

@ddalp ddalp commented Nov 16, 2019

#3068

-Hook up property keyboardDismissMode in ScrollViewManager.
-When manipulation starts and if keyboardDismissMode is on-drag, issue TryHide though SIP event handler.

  • Some tweak to SIP Event Handler code to be able to share in the RNW's code base, and call GetForUIContext instead of GetForCurrentView on newer build.
Microsoft Reviewers: Open in CodeFlow

@ddalp ddalp requested a review from a team as a code owner November 16, 2019 00:36
@ghost ghost added the vnext label Nov 16, 2019
void SIPEventHandler::AttachView(XamlView xamlView, bool fireKeyboardEvents) {
m_fireKeyboradEvents = fireKeyboardEvents;

if (Is19H1OrHigher()) {
Copy link
Contributor

@licanhua licanhua Nov 19, 2019

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

Copy link
Contributor Author

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)

Copy link
Contributor Author

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(
Copy link
Contributor

@licanhua licanhua Nov 19, 2019

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) {
Copy link
Contributor

@licanhua licanhua Nov 19, 2019

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) {
Copy link
Contributor

@licanhua licanhua Nov 19, 2019

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;
Copy link
Contributor

@licanhua licanhua Nov 19, 2019

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;
Copy link
Contributor

@licanhua licanhua Nov 19, 2019

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();
Copy link
Contributor

@licanhua licanhua Nov 20, 2019

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

Copy link
Contributor Author

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) {
Copy link
Contributor

@licanhua licanhua Nov 20, 2019

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) {
Copy link
Contributor

@licanhua licanhua Nov 20, 2019

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() {
Copy link
Contributor

@licanhua licanhua Nov 20, 2019

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

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 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() {
Copy link
Contributor

@licanhua licanhua Nov 20, 2019

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());
}
Copy link
Contributor

@licanhua licanhua Nov 20, 2019

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

Copy link
Contributor

@licanhua licanhua left a comment

Choose a reason for hiding this comment

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

:shipit:

@ddalp ddalp merged commit 65f7d80 into microsoft:master Nov 22, 2019
licanhua added a commit that referenced this pull request Nov 22, 2019
ghost pushed a commit that referenced this pull request Nov 22, 2019
* Revert "Support ScrollView keyboardDismissMode (#3665)"

This reverts commit 65f7d80.

* Change files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants