Re: Position of my item in the statusBar
Re: Position of my item in the statusBar
- Subject: Re: Position of my item in the statusBar
- From: Erik Stainsby <email@hidden>
- Date: Mon, 17 Sep 2012 18:55:54 -0700
On 2012-09-17, at 2:17 PM, Kyle Sluder <email@hidden> wrote:
> On Mon, Sep 17, 2012, at 02:12 PM, Tim Schröder wrote:
>> Use something like this:
>>
>> NSRect frame = [[statusItem valueForKey:@"window"] frame];
>
> Don't do this. -[NSStatusItem window] is private API and is not
> guaranteed to exist.
>
> Create a view, assign it to your status item, and use that for your
> frame.
>
> --Kyle Sluder
Is it any safer to assume a window will be returned from this code ?
RSStatusItemViewController * _statusViewCtrl = [[RSStatusItemViewController alloc]init];
[self.statusItem setView:[_statusViewCtrl view]];
NSWindow * statusWindow = [[_statusViewCtrl view] window];
NSRect rect = [statusWindow frame];
I mean I assign the view through setView: - does that implicitly guarantee there will be a window context when I invoke [myView window] later on? I see nothing contractual. It works, and I am glad, but I don't know if I can trust it.
Erik Stainsby
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden