简体   繁体   中英

Losing focus and clicking on a close button of my window?

I've a method triggered when a NSTextField looses focus. This method displays a popup sheet over my current window.

Everything works great except when I've typed something in the text field and successively I close the window by clicking on the close button. In this case:

  • the text field loses focus and the method is triggered and it shows the popup

but

  • the window is dismissed anyway, because I've clicked the Close button, so the popup is visible only for few seconds.

Thanks

您应该创建一个NSWindowDelegate并实现-windowShouldClose:如果弹出窗口可见或者文本字段是先前的第一响应者(否则,您正在确定文本字段失去了焦点),则返回NO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM