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: Kyle Sluder <email@hidden>
- Date: Mon, 17 Sep 2012 19:15:23 -0700
On Sep 17, 2012, at 6:55 PM, Erik Stainsby <email@hidden> wrote:
> 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 ?
Sadly it's not absolutely guaranteed, because Apple never outright claims that the view will be placed in a window, but since the express purpose of having -setView: is so you can do normal view things like respond to events, and events are dispatched by window, it's fairly safe to assume it will work. Certainly a lot safer than assuming the private -window method will continue to exist forever.
Personally, I believe that if Apple hands you Thing A and Thing B, and gives you a way to hook A and B together, then the documentation should explicitly describe the entire interaction between A and B. Pragmatically, this isn't the case.
--Kyle Sluder
_______________________________________________
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