|
|
@ -108,15 +108,12 @@
|
|
|
|
// If we want to receive key events, we either need to be in the responder chain of the key view,
|
|
|
|
// If we want to receive key events, we either need to be in the responder chain of the key view,
|
|
|
|
// or else we can install a local monitor. The consequence of this heavy-handed approach is that
|
|
|
|
// or else we can install a local monitor. The consequence of this heavy-handed approach is that
|
|
|
|
// we receive events for all controls, not just Dear ImGui widgets. If we had native controls in our
|
|
|
|
// we receive events for all controls, not just Dear ImGui widgets. If we had native controls in our
|
|
|
|
// window, we'd want to be much more careful than just ingesting the complete event stream, though we
|
|
|
|
// window, we'd want to be much more careful than just ingesting the complete event stream.
|
|
|
|
// do make an effort to be good citizens by passing along events when Dear ImGui doesn't want to capture.
|
|
|
|
// To match the behavior of other backends, we pass every event down to the OS.
|
|
|
|
NSEventMask eventMask = NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged | NSEventTypeScrollWheel;
|
|
|
|
NSEventMask eventMask = NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged | NSEventTypeScrollWheel;
|
|
|
|
[NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event)
|
|
|
|
[NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BOOL wantsCapture = ImGui_ImplOSX_HandleEvent(event, self.view);
|
|
|
|
ImGui_ImplOSX_HandleEvent(event, self.view);
|
|
|
|
if (event.type == NSEventTypeKeyDown && wantsCapture)
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return event;
|
|
|
|
return event;
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|