git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
Rive: track mouse globally via NSEvent monitor for out-of-bounds tracking
commitb56740ae2d2b2fe114ecbbc216ed5508f17e8157 authorMark <mark.eibes@gmail.com> dateSat 14 Feb 2026, 00:39 (8 months ago) parent484586d
1 file changed+13−1
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+13−1
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+13−1
@@ -987,7 +987,19 @@ RCT_EXPORT_MODULE(MacOSScrollView)
987987 __weak typeof(self) weakSelf = self;
988988 _mouseMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskMouseMoved handler:^NSEvent *(NSEvent *event) {
989989 __strong typeof(weakSelf) strongSelf = weakSelf;
990− if (strongSelf.riveView) [strongSelf.riveView mouseMoved:event];
990+ if (!strongSelf || !strongSelf.riveView || !strongSelf.viewModel) return event;
991+ RiveModel *model = strongSelf.viewModel.riveModel;
992+ if (!model) return event;
993+ RiveStateMachineInstance *sm = [model valueForKey:@"stateMachine"];
994+ RiveArtboard *ab = [model valueForKey:@"artboard"];
995+ if (!sm || !ab) return event;
996+ CGPoint loc = [strongSelf.riveView convertPoint:event.locationInWindow fromView:nil];
997+ loc.y = strongSelf.riveView.bounds.size.height - loc.y;
998+ CGPoint artLoc = [strongSelf.riveView artboardLocationFromTouchLocation:loc
999+ inArtboard:[ab bounds]
1000+ fit:strongSelf.viewModel.fit
1001+ alignment:strongSelf.viewModel.alignment];
1002+ [sm touchMovedAtLocation:artLoc];
9911003 return event;
9921004 }];
9931005 } else if (!self.window && _mouseMonitor) {