Mac Cocoa UI Api

来源:互联网 发布:java策略模式的优点 编辑:程序博客网 时间:2024/06/04 00:18

NSWindow setExcludedFromWindowsMenu 

设定是否在 Window Menu 中显示。YES 不显示,NO 显示。

NSResponder becomeFirstResponder

Notifies the receiver that it’s about to become first responder in its NSWindow.

- (BOOL)becomeFirstResponder
Discussion

The default implementation returns YES, accepting first responder status. Subclasses can override this method to update state or perform some action such as highlighting the selection, or to return NO, refusing first responder status.

Use the NSWindow makeFirstResponder: method, not this method, to make an object the first responder. Never invoke this method directly.

界面上的 TextField 首先响应,可以实现 打开界面时,焦点定位。

    NSButton *closeButton = [[self window] standardWindowButton:NSWindowCloseButton]; 

    [closeButton setTarget:self]; 

    [closeButton setAction:@selector(onClickCancel:)]; 


[[self window] standardWindowButton:NSWindowCloseButton]获得当前window 左上角  

[closeButton setTarget:self]; 

[closeButton setAction:@selector(onClickCancel:)]; 重载  方法,可以在关闭时,添加自己的实现。

startAnimation:

Starts the animation of an indeterminate progress indicator.

- (void)startAnimation:(id)sender
Parameters
sender

The object sending the message.

Discussion

Does nothing for a determinate progress indicator.

    NSButton *miniaturizeButton = [[self window] standardWindowButton:NSWindowMiniaturizeButton]; //获得当前window的最小化button

    [miniaturizeButton setTarget:self]; //将self 设定为 target

    [miniaturizeButton setAction:@selector(onClickMiniaturize:)];//绑定最小化调用函数

- (void) onClickMiniaturize:(id)sender

{

    [[self window] miniaturize:self];//将window 最小化

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidDeminiaturize) name:NSWindowDidDeminiaturizeNotification object:nil];//监听window 最小化事件


原创粉丝点击