git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
Forward scrollWheel events through video player to parent scroll view
commit30d9e5fa49f84a9a5c9d5b4c0195368c3220b398 authorMark <mark.eibes@gmail.com> dateSun 15 Feb 2026, 12:20 (8 months ago) parent282c3ea
1 file changed+48−16
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+48−16
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+48−16
@@ -1897,11 +1897,37 @@ RCT_EXPORT_VIEW_PROPERTY(patternScale, CGFloat)
18971897// MARK: - NSSplitView
18981898// ===========================================================================
18991899
1900+@interface RCTSplitPaneWrapper : NSView
1901+@property (nonatomic, strong) NSView *reactChild;
1902+@end
1903+
1904+@implementation RCTSplitPaneWrapper
1905+- (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
1906+ // When NSSplitView resizes us, resize the React child to fill and re-trigger Yoga layout
1907+ if (_reactChild) {
1908+ _reactChild.frame = self.bounds;
1909+ if ([_reactChild respondsToSelector:@selector(reactSetFrame:)]) {
1910+ ((void (*)(id, SEL, CGRect))objc_msgSend)(_reactChild, @selector(reactSetFrame:), self.bounds);
1911+ }
1912+ }
1913+}
1914+- (void)setFrameSize:(NSSize)newSize {
1915+ [super setFrameSize:newSize];
1916+ if (_reactChild) {
1917+ _reactChild.frame = self.bounds;
1918+ if ([_reactChild respondsToSelector:@selector(reactSetFrame:)]) {
1919+ ((void (*)(id, SEL, CGRect))objc_msgSend)(_reactChild, @selector(reactSetFrame:), self.bounds);
1920+ }
1921+ }
1922+}
1923+@end
1924+
19001925@interface RCTSplitView : NSView <NSSplitViewDelegate>
19011926@property (nonatomic, strong) NSSplitView *splitView;
19021927@property (nonatomic, assign) BOOL isVertical;
19031928@property (nonatomic, assign) CGFloat dividerThicknessValue;
1904−@property (nonatomic, strong) NSMutableArray<NSView *> *panes;
1929+@property (nonatomic, strong) NSMutableArray<NSView *> *reactChildren;
1930+@property (nonatomic, strong) NSMutableArray<RCTSplitPaneWrapper *> *wrappers;
19051931@end
19061932
19071933@implementation RCTSplitView
@@ -1913,7 +1939,8 @@ RCT_EXPORT_VIEW_PROPERTY(patternScale, CGFloat)
19131939 _splitView.dividerStyle = NSSplitViewDividerStyleThin;
19141940 _splitView.vertical = YES;
19151941 _splitView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
1916− _panes = [NSMutableArray new];
1942+ _reactChildren = [NSMutableArray new];
1943+ _wrappers = [NSMutableArray new];
19171944 _isVertical = YES;
19181945 [self addSubview:_splitView];
19191946 }
@@ -1931,17 +1958,31 @@ RCT_EXPORT_VIEW_PROPERTY(patternScale, CGFloat)
19311958}
19321959
19331960- (void)insertReactSubview:(NSView *)subview atIndex:(NSInteger)atIndex {
1934− [_panes insertObject:subview atIndex:MIN(atIndex, (NSInteger)_panes.count)];
1935− [_splitView addSubview:subview];
1961+ NSInteger idx = MIN(atIndex, (NSInteger)_reactChildren.count);
1962+ [_reactChildren insertObject:subview atIndex:idx];
1963+
1964+ // Wrap the React child in a plain NSView so NSSplitView controls the wrapper's frame,
1965+ // and we relay the size to the React child, triggering Yoga re-layout at the correct size.
1966+ RCTSplitPaneWrapper *wrapper = [[RCTSplitPaneWrapper alloc] initWithFrame:NSZeroRect];
1967+ wrapper.autoresizesSubviews = YES;
1968+ wrapper.reactChild = subview;
1969+ [wrapper addSubview:subview];
1970+ [_wrappers insertObject:wrapper atIndex:idx];
1971+ [_splitView addSubview:wrapper];
19361972}
19371973
19381974- (void)removeReactSubview:(NSView *)subview {
1939− [_panes removeObject:subview];
1940− [subview removeFromSuperview];
1975+ NSUInteger idx = [_reactChildren indexOfObject:subview];
1976+ if (idx != NSNotFound) {
1977+ RCTSplitPaneWrapper *wrapper = _wrappers[idx];
1978+ [wrapper removeFromSuperview];
1979+ [_wrappers removeObjectAtIndex:idx];
1980+ [_reactChildren removeObjectAtIndex:idx];
1981+ }
19411982}
19421983
19431984- (NSArray<NSView *> *)reactSubviews {
1944− return [_panes copy];
1985+ return [_reactChildren copy];
19451986}
19461987
19471988- (void)didUpdateReactSubviews {
@@ -1959,15 +2000,6 @@ RCT_EXPORT_VIEW_PROPERTY(patternScale, CGFloat)
19592000 [_splitView adjustSubviews];
19602001}
19612002
1962−// After NSSplitView resizes panes, tell React about the new sizes
1963−- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize {
1964− [splitView adjustSubviews];
1965− for (NSView *pane in _panes) {
1966− CGRect f = pane.frame;
1967− ((void (*)(id, SEL, CGRect))objc_msgSend)(pane, @selector(reactSetFrame:), f);
1968− }
1969−}
1970−
19712003- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex {
19722004 return proposedMinimumPosition + 50;
19732005}