Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "added check for double click on textInput component view connecting it to WM_LBUTTONDBLCLK",
"packageName": "react-native-windows",
"email": "email not defined",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,19 @@ WPARAM PointerRoutedEventArgsToMouseWParam(
return wParam;
}

bool WindowsTextInputComponentView::IsDoubleClick() {
using namespace std::chrono;

auto now = steady_clock::now();
auto duration = duration_cast<milliseconds>(now - m_lastClickTime).count();

const int DOUBLE_CLICK_TIME_MS = ::GetDoubleClickTime();

m_lastClickTime = now;

return (duration < DOUBLE_CLICK_TIME_MS);
}

void WindowsTextInputComponentView::OnPointerPressed(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
UINT msg = 0;
Expand All @@ -637,7 +650,11 @@ void WindowsTextInputComponentView::OnPointerPressed(
if (pp.PointerDeviceType() == winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse) {
switch (pp.Properties().PointerUpdateKind()) {
case winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::LeftButtonPressed:
msg = WM_LBUTTONDOWN;
if (IsDoubleClick()) {
msg = WM_LBUTTONDBLCLK;
} else {
msg = WM_LBUTTONDOWN;
}
break;
case winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::MiddleButtonPressed:
msg = WM_MBUTTONDOWN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct WindowsTextInputComponentView
std::optional<std::string> getAccessiblityValue() noexcept override;
void setAcccessiblityValue(std::string &&value) noexcept override;
bool getAcccessiblityIsReadOnly() noexcept override;
bool IsDoubleClick();

WindowsTextInputComponentView(
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
Expand Down Expand Up @@ -140,6 +141,7 @@ struct WindowsTextInputComponentView
DWORD m_propBitsMask{0};
DWORD m_propBits{0};
HCURSOR m_hcursor{nullptr};
std::chrono::steady_clock::time_point m_lastClickTime{};
std::vector<facebook::react::CompWindowsTextInputSubmitKeyEventsStruct> m_submitKeyEvents;
};

Expand Down
Loading