You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be great if we could add hitSlop support. Small MenuView buttons are hard to pressed and larger ones may not look good.
I just added it locally. It was pretty straight forward. This is my diff
diff --git a/node_modules/@react-native-menu/menu/ios/MenuView.swift b/node_modules/@react-native-menu/menu/ios/MenuView.swift
index 4333aca..2313b78 100644
--- a/node_modules/@react-native-menu/menu/ios/MenuView.swift+++ b/node_modules/@react-native-menu/menu/ios/MenuView.swift@@ -50,6 +50,9 @@ class MenuView: UIButton {
}
}
++ @objc var hitSlop: UIEdgeInsets = .zero+
override init(frame: CGRect) {
super.init(frame: frame)
self.setup()
@@ -77,6 +80,23 @@ class MenuView: UIButton {
super.reactSetFrame(frame);
};
+ override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {+ if hitSlop == .zero || !self.isEnabled || self.isHidden {+ return super.point(inside: point, with: event)+ }++ // Create a larger hit frame that extends beyond the view's bounds+ let largerFrame = CGRect(+ x: self.bounds.origin.x - hitSlop.left,+ y: self.bounds.origin.y - hitSlop.top,+ width: self.bounds.size.width + hitSlop.left + hitSlop.right,+ height: self.bounds.size.height + hitSlop.top + hitSlop.bottom+ )++ // Check if the point is within the larger frame+ return largerFrame.contains(point)+ }+
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
diff --git a/node_modules/@react-native-menu/menu/ios/RCTUIMenuManager.m b/node_modules/@react-native-menu/menu/ios/RCTUIMenuManager.m
index 42b08ee..9cf9f06 100644
--- a/node_modules/@react-native-menu/menu/ios/RCTUIMenuManager.m+++ b/node_modules/@react-native-menu/menu/ios/RCTUIMenuManager.m@@ -24,4 +24,6 @@ @interface RCT_EXTERN_MODULE(RCTUIMenu, RCTViewManager)
*/
RCT_EXPORT_VIEW_PROPERTY(themeVariant, NSString)
+RCT_EXPORT_VIEW_PROPERTY(hitSlop, UIEdgeInsets)+
@end
The text was updated successfully, but these errors were encountered:
Would be great if we could add
hitSlop
support. SmallMenuView
buttons are hard to pressed and larger ones may not look good.I just added it locally. It was pretty straight forward. This is my diff
The text was updated successfully, but these errors were encountered: