macOS Tahoe 26.3 - System Is Playing NSBeep At Inappropriate Times When Text Editing Ends Via -cancelOperation: (field editor)

When I end editing pressing the escape key, the system sometimes plays NSBeep().

I noticed this with NSBrowser. Every time I press escape to end editing the system beeps. At first I thought it was somewhere in my app but I set a symbolic breakpoint and discovered it was not coming from my code.

I filed FB22127038.

Since then I discovered that NSBeep playing at inappropriate times is not exclusive to NSBrowser. It appears if there is a NSTableView in the window and you just press the escape key (even if you aren't editing anything) AppKit beeps. It can be traced to:

#0 0x0000000199e3184c in NSBeep ()

#1 0x000000019aa03fac in -[NSWindow doCommandBySelector:] ()

#2 0x000000019ac1d01c in -[NSTableView(NSTableViewViewBased) cancelOperation:] ()

I hit something similar today. I noticed that my external keyboard emits 4 keyDown events for the esc key. That does not happen for the MacBook keyboard, it correctly emits a single esc key down event. Are you hitting issues with an external keyboard as well?

It looks like my keyboard was messed up. After a "Soft Reset" it is working as expected now.

I did programmatically change first responder via a call to -makeFirstResponder inside my responder's -cancelOperation:

I've been doing this for years no issue until Tahoe 26.3. I had a reason for doing this (to end editing). I think it was to workaround some kind of bug. Now it appears that the cancelOperation 'event' wraps back to the window and NSWindow just beeps.

In the case of view that uses NSBrowser I tried changing the -makeFirstResponder: call and passed in the browser itself instead of nil but I still get a beep. It still wraps the event back to the window but that key event I think should not be in the event queue anymore.

In another view that uses a table view this causes a bunch of key events to get stuck in the queue and they get sent to the window later and I get a beep beep beep. In the non-browser case just passing in that table view to makeFirstResponder: seems to fix it. IN the view that uses the browser I seem to get that beep no matter what.

Just overriding -cancelOperation in NSWindow subclass and not calling super is my workaround for now.

macOS Tahoe 26.3 - System Is Playing NSBeep At Inappropriate Times When Text Editing Ends Via -cancelOperation: (field editor)
 
 
Q