How Panels Work

How Panels Work

A panel is a special kind of window, typically serving an auxiliary function in an application. The NSPanelsubclass of NSWindow adds a few special behaviors to windows in support of the role panels play:

  • By default panels are not released when they’re closed, because they’re usually lightweight and often reused.

  • Onscreen panels, except for alert dialogs, are removed from the screen when the application isn’t active and are restored when the application again becomes active. This reduces screen clutter.

    Specifically, the NSWindow implementation of the hidesOnDeactivate method returns NO, but theNSPanel implementation of the same method returns YES.

  • Panels can become the key window, but they cannot become the main window.

  • If a panel is the key window and has a close button, it closes itself when the user presses the Escape key.

In addition to these automatic behaviors, the NSPanel class allows you to configure certain other behaviors common to some kinds of panels:

  • You can prevent a panel from becoming the key window unless the user clicks in a view that responds to typing. This prevents the key window from shifting to the panel unnecessarily. ThesetBecomesKeyOnlyIfNeeded: method controls this behavior.

  • Palettes and similar panels can be made to float above standard windows and other panels. This prevents them from being covered and keeps them readily available to the user. ThesetFloatingPanel: method controls this behavior.

  • A panel can be made to receive mouse and keyboard events even when another window or panel is being run modally or in a modal session. This permits actions in the panel to affect the modal window or panel. The setWorksWhenModal: method controls this behavior. See “How Modal Windows Work” for more information on modal windows and panels.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值