Neglecting a sheet with a single text field using an escape key

So this is my setup:

Trivial NSWindowwith one NSTextFieldfor a custom entry plus Accept ' NSButton.

The window is displayed for my document window as a sheet using beginSheetModalForWindow:completionHandler:

I would like to close the sheet when the user presses the evacuation key, however, all I get is a funny system beep that tells me that he is not really expecting an evacuation key.

There are several similar questions in which we should just check cancelOperationsomewhere in the defendant chain. The fact is that my window controller (for a window / dialog on a sheet) is not even in the responder chain when I check it in the debugger.

For a sheet displayed in such a way that the above chain of responders is still touching my document window. Weird

Therefore, any tips on how to properly connect to cancelOperationor to the Escape key will be greatly appreciated!

+4
source share
1 answer

, , , "", . , Escape IB, . , , ""; , , AppKit .

, , , , , NSWindowController ; . Apple . , , , , . , - , . , .

+3

Source: https://habr.com/ru/post/1608939/


All Articles