Skip to content
Closed
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
1 change: 0 additions & 1 deletion packages/react-native/Libraries/Types/CoreEventTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ export type NativeTouchEvent = $ReadOnly<{
* The Y position of the touch, relative to the element
*/
locationY: number,

/**
* The X position of the touch, relative to the screen
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ void setTouchPayloadOnObject(
object.setProperty(runtime, "target", touch.target);
object.setProperty(runtime, "timestamp", touch.timestamp * 1000);
object.setProperty(runtime, "force", touch.force);
#if TARGET_OS_OSX // [macOS
object.setProperty(runtime, "button", touch.button);
object.setProperty(runtime, "altKey", touch.altKey);
object.setProperty(runtime, "ctrlKey", touch.ctrlKey);
object.setProperty(runtime, "shiftKey", touch.shiftKey);
object.setProperty(runtime, "metaKey", touch.metaKey);
#endif // macOS]
}

#if RN_DEBUG_STRING_CONVERTIBLE
Expand All @@ -49,13 +42,6 @@ std::vector<DebugStringConvertibleObject> getDebugProps(
{"target", getDebugDescription(touch.target, options)},
{"force", getDebugDescription(touch.force, options)},
{"timestamp", getDebugDescription(touch.timestamp, options)},
#if TARGET_OS_SX // [macOS
{"button", getDebugDescription(touch.button, options)},
{"altKey", getDebugDescription(touch.altKey, options)},
{"ctrlKey", getDebugDescription(touch.ctrlKey, options)},
{"shiftKey", getDebugDescription(touch.shiftKey, options)},
{"metaKey", getDebugDescription(touch.metaKey, options)},
#endif // macOS]
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,6 @@ struct BaseTouch {
* The time in seconds when the touch occurred or when it was last mutated.
*/
Float timestamp;
#if TARGET_OS_OSX // [macOS
/*
* The button indicating which pointer is used.
*/
int button;

/*
* A flag indicating if the alt key is pressed.
*/
bool altKey;

/*
* A flag indicating if the control key is pressed.
*/
bool ctrlKey;

/*
* A flag indicating if the shift key is pressed.
*/
bool shiftKey;

/*
* A flag indicating if the meta key is pressed.
*/
bool metaKey;
#endif // macOS]

/*
* The particular implementation of `Hasher` and (especially) `Comparator`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#include "HostPlatformTouch.h"
#include "Touch.h"

namespace facebook::react {

void setTouchPayloadOnObject(
jsi::Object& object,
jsi::Runtime& runtime,
const HostPlatformTouch& touch) {
setTouchPayloadOnObject(object, runtime, static_cast<const BaseTouch&>(touch));
#if TARGET_OS_OSX // [macOS
object.setProperty(runtime, "button", touch.button);
object.setProperty(runtime, "altKey", touch.altKey);
object.setProperty(runtime, "ctrlKey", touch.ctrlKey);
object.setProperty(runtime, "shiftKey", touch.shiftKey);
object.setProperty(runtime, "metaKey", touch.metaKey);
#endif // macOS]
}

#if RN_DEBUG_STRING_CONVERTIBLE

std::string getDebugName(const HostPlatformTouch& /*touch*/) {
return "Touch";
}

std::vector<DebugStringConvertibleObject> getDebugProps(
const HostPlatformTouch& touch,
DebugStringConvertibleOptions options) {
auto debugProps = getDebugProps(static_cast<const BaseTouch&>(touch), options);
debugProps.insert(
debugProps.end(),
{
{"button", getDebugDescription(touch.button, options)},
{"altKey", getDebugDescription(touch.altKey, options)},
{"ctrlKey", getDebugDescription(touch.ctrlKey, options)},
{"shiftKey", getDebugDescription(touch.shiftKey, options)},
{"metaKey", getDebugDescription(touch.metaKey, options)},
});
return debugProps;
};

#endif

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,32 @@
#include <react/renderer/components/view/BaseTouch.h>

namespace facebook::react {
using HostPlatformTouch = BaseTouch;

struct HostPlatformTouch : public BaseTouch {
/*
* The button indicating which pointer is used.
*/
int button;

/*
* A flag indicating if the alt key is pressed.
*/
bool altKey;

/*
* A flag indicating if the control key is pressed.
*/
bool ctrlKey;

/*
* A flag indicating if the shift key is pressed.
*/
bool shiftKey;

/*
* A flag indicating if the meta key is pressed.
*/
bool metaKey;
};

} // namespace facebook::react
Loading