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": "prerelease",
"comment": "[Fabric] Add pointer pressed, released, moved and wheelch changed events",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
75 changes: 75 additions & 0 deletions vnext/Microsoft.ReactNative/Composition.Input.idl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,79 @@ namespace Microsoft.ReactNative.Composition.Input
Windows.System.VirtualKey OriginalKey { get; };
}

interface IPointerPointTransform
{
IPointerPointTransform Inverse { get; };
Boolean TryTransform(Windows.Foundation.Point inPoint, out Windows.Foundation.Point outPoint);
Boolean TryTransformBounds(Windows.Foundation.Rect inRect, out Windows.Foundation.Rect outRect);
};

enum PointerDeviceType
{
Touch = 0,
Pen,
Mouse,
Touchpad,
};

enum PointerUpdateKind
{
Other = 0,
LeftButtonPressed,
LeftButtonReleased,
RightButtonPressed,
RightButtonReleased,
MiddleButtonPressed,
MiddleButtonReleased,
XButton1Pressed,
XButton1Released,
XButton2Pressed,
XButton2Released,
};

runtimeclass PointerPointProperties
{
Windows.Foundation.Rect ContactRect { get; };
Boolean IsBarrelButtonPressed { get; };
Boolean IsCanceled { get; };
Boolean IsEraser { get; };
Boolean IsHorizontalMouseWheel { get; };
Boolean IsInRange { get; };
Boolean IsInverted { get; };
Boolean IsLeftButtonPressed { get; };
Boolean IsMiddleButtonPressed { get; };
Boolean IsPrimary { get; };
Boolean IsRightButtonPressed { get; };
Boolean IsXButton1Pressed { get; };
Boolean IsXButton2Pressed { get; };
Int32 MouseWheelDelta { get; };
Single Orientation { get; };
PointerUpdateKind PointerUpdateKind{ get; };
Single Pressure { get; };
Boolean TouchConfidence { get; };
Single Twist { get; };
Single XTilt { get; };
Single YTilt { get; };
};

runtimeclass PointerPoint
{
UInt32 FrameId { get; };
Boolean IsInContact{ get; };
PointerDeviceType PointerDeviceType { get; };
UInt32 PointerId{ get; };
Windows.Foundation.Point Position { get; };
PointerPointProperties Properties{ get; };
UInt64 Timestamp { get; };
PointerPoint GetTransformedPoint(
IPointerPointTransform transform);
};

runtimeclass PointerRoutedEventArgs : RoutedEventArgs
{
PointerPoint GetCurrentPoint(Int32 tag);
Boolean Handled;
Windows.System.VirtualKeyModifiers KeyModifiers { get; };
};

} // namespace Microsoft.ReactNative.Composition.Input
4 changes: 0 additions & 4 deletions vnext/Microsoft.ReactNative/CompositionRootView.idl
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ namespace Microsoft.ReactNative
Int64 SendMessage(UInt32 Msg, UInt64 WParam, Int64 LParam);

Object GetUiaProvider();

//void OnPointerPressed(PointerPressedArgs args);
//void OnMouseUp(Windows.Foundation.Point point);
void OnScrollWheel(Windows.Foundation.Point point, Int32 delta);
}

} // namespace Microsoft.ReactNative
9 changes: 8 additions & 1 deletion vnext/Microsoft.ReactNative/Fabric/ComponentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,20 @@ struct IComponentView {
virtual RECT getClientRect() const noexcept = 0;
virtual void onFocusLost() noexcept = 0;
virtual void onFocusGained() noexcept = 0;
virtual void onPointerPressed(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept = 0;
virtual void onPointerReleased(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept = 0;
virtual void onPointerMoved(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept = 0;
virtual void onPointerWheelChanged(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept = 0;
virtual void onKeyDown(
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept = 0;
virtual void onKeyUp(
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept = 0;
virtual bool ScrollWheel(facebook::react::Point pt, int32_t delta) noexcept = 0;
virtual bool focusable() const noexcept = 0;
virtual facebook::react::SharedViewEventEmitter eventEmitterAtPoint(facebook::react::Point pt) noexcept = 0;
virtual facebook::react::SharedViewEventEmitter eventEmitter() noexcept = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,30 @@ void AbiCompositionViewComponentView::onKeyUp(
Super::onKeyUp(source, args);
}

void AbiCompositionViewComponentView::onPointerPressed(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
Builder().OnPointerPressed(args);
Super::onPointerPressed(args);
}

void AbiCompositionViewComponentView::onPointerReleased(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
Builder().OnPointerReleased(args);
Super::onPointerReleased(args);
}

void AbiCompositionViewComponentView::onPointerMoved(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
Builder().OnPointerMoved(args);
Super::onPointerMoved(args);
}

void AbiCompositionViewComponentView::onPointerWheelChanged(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
Builder().OnPointerWheelChanged(args);
Super::onPointerWheelChanged(args);
}

std::vector<facebook::react::ComponentDescriptorProvider>
AbiCompositionViewComponentView::supplementalComponentDescriptorProviders() noexcept {
return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ struct AbiCompositionViewComponentView : CompositionBaseComponentView {
void onKeyUp(
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
void onPointerPressed(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
void onPointerReleased(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
void onPointerMoved(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
void onPointerWheelChanged(
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
std::vector<facebook::react::ComponentDescriptorProvider> supplementalComponentDescriptorProviders() noexcept
override;
facebook::react::Props::Shared props() noexcept override;
Expand Down
Loading