Skip to content

Commit 21a1047

Browse files
acoates-msiamAbhi-916Abhijeet Jha
authored
[0.74] Cherry-picks - Tooltip location scale + TextInput double click (#15388)
* Tooltip positioned incorrectly on non 100% scale factor (#15382) * Tooltip positioned incorrectly on non 100% scale factor * Change files * Textinput double clicking selects text (#14515) * added check for double click on textInput component view connecting it to WM_LBUTTONDBLCLK * Change files * updated for lint fix * updated to remove position( Distance check) --------- Co-authored-by: Abhijeet Jha <[email protected]> * update change files --------- Co-authored-by: Abhijeet Jha <[email protected]> Co-authored-by: Abhijeet Jha <[email protected]>
1 parent de4af71 commit 21a1047

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "added check for double click on textInput component view connecting it to WM_LBUTTONDBLCLK",
4+
"packageName": "react-native-windows",
5+
"email": "email not defined",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Tooltip positioned incorrectly on non 100% scale factor",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,19 @@ WPARAM PointerRoutedEventArgsToMouseWParam(
631631
return wParam;
632632
}
633633

634+
bool WindowsTextInputComponentView::IsDoubleClick() {
635+
using namespace std::chrono;
636+
637+
auto now = steady_clock::now();
638+
auto duration = duration_cast<milliseconds>(now - m_lastClickTime).count();
639+
640+
const int DOUBLE_CLICK_TIME_MS = ::GetDoubleClickTime();
641+
642+
m_lastClickTime = now;
643+
644+
return (duration < DOUBLE_CLICK_TIME_MS);
645+
}
646+
634647
void WindowsTextInputComponentView::OnPointerPressed(
635648
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
636649
UINT msg = 0;
@@ -647,7 +660,11 @@ void WindowsTextInputComponentView::OnPointerPressed(
647660
if (pp.PointerDeviceType() == winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse) {
648661
switch (pp.Properties().PointerUpdateKind()) {
649662
case winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::LeftButtonPressed:
650-
msg = WM_LBUTTONDOWN;
663+
if (IsDoubleClick()) {
664+
msg = WM_LBUTTONDBLCLK;
665+
} else {
666+
msg = WM_LBUTTONDOWN;
667+
}
651668
break;
652669
case winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::MiddleButtonPressed:
653670
msg = WM_MBUTTONDOWN;

vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct WindowsTextInputComponentView
7070
std::optional<std::string> getAccessiblityValue() noexcept override;
7171
void setAcccessiblityValue(std::string &&value) noexcept override;
7272
bool getAcccessiblityIsReadOnly() noexcept override;
73+
bool IsDoubleClick();
7374

7475
WindowsTextInputComponentView(
7576
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
@@ -141,6 +142,7 @@ struct WindowsTextInputComponentView
141142
DWORD m_propBitsMask{0};
142143
DWORD m_propBits{0};
143144
HCURSOR m_hcursor{nullptr};
145+
std::chrono::steady_clock::time_point m_lastClickTime{};
144146
std::vector<facebook::react::CompWindowsTextInputSubmitKeyEventsStruct> m_submitKeyEvents;
145147
};
146148

vnext/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void TooltipTracker::ShowTooltip(const winrt::Microsoft::ReactNative::ComponentV
266266
static_cast<int>((tm.width + tooltipHorizontalPadding + tooltipHorizontalPadding) * scaleFactor);
267267
tooltipData->height = static_cast<int>((tm.height + tooltipTopPadding + tooltipBottomPadding) * scaleFactor);
268268

269-
POINT pt = {static_cast<LONG>(m_pos.X), static_cast<LONG>(m_pos.Y)};
269+
POINT pt = {static_cast<LONG>(m_pos.X * scaleFactor), static_cast<LONG>(m_pos.Y * scaleFactor)};
270270
ClientToScreen(parentHwnd, &pt);
271271

272272
RegisterTooltipWndClass();

0 commit comments

Comments
 (0)