mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-06 06:34:35 +00:00
Fix duplicate event dispatch in Cocoa event pump
Prevent mouse and keyboard events from being processed twice by skipping [super sendEvent:] for events SDL has already handled via Cocoa_DispatchEvent. Other event types still go through AppKit's normal handling.
This commit is contained in:
parent
ca537d651b
commit
dd52dd8995
1 changed files with 8 additions and 0 deletions
|
|
@ -97,6 +97,14 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
|||
{
|
||||
if (s_bShouldHandleEventsInSDLApplication) {
|
||||
Cocoa_DispatchEvent(theEvent);
|
||||
|
||||
// Avoid double-dispatching mouse and keyboard events. They are already handled in Cocoa_DispatchEvent.
|
||||
// Other event types should still go through AppKit's normal handling.
|
||||
NSEventType type = [theEvent type];
|
||||
if ((type >= NSEventTypeLeftMouseDown && type <= NSEventTypeMouseExited) ||
|
||||
(type >= NSEventTypeKeyDown && type <= NSEventTypeFlagsChanged)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[super sendEvent:theEvent];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue