Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to handle close button of window in cocoa

Tags:

cocoa

window

I am developing cocoa application having multiple windows. There is a red close button on left corner of window. And I want to handle click event of close button so that I can show message to ask user whether he wants to close window or not. If user accept to close window then application will be terminated otherwise same window shown to user. Any idea how can I handle click event of close button???

like image 202
Amrinder Singh Avatar asked Dec 27 '11 11:12

Amrinder Singh


1 Answers

Please look at NSWindowDelegate protocol reference, the method which you are looking for is-

- (BOOL)windowShouldClose:(id)sender
like image 179
Devarshi Avatar answered Oct 30 '22 02:10

Devarshi