Re: NSStatusItem position problem
Re: NSStatusItem position problem
- Subject: Re: NSStatusItem position problem
- From: Andy Lee <email@hidden>
- Date: Mon, 26 Mar 2007 18:46:43 -0400
On Mar 26, 2007, at 6:02 PM, Orr Philip wrote:
I can then access the _fWindow ._frame point and size variables by
directly accessing the memory location relative to the windows
memory address and rebuilding the needed NSRect, see below:
INF_StatusItem *menubarItem = (INF_StatusItem *) statusItem;
NSPoint *itemPoint = (NSPoint *) menubarItem->fWindow + 1;
NSSize *itemSize = (NSSize *) menubarItem->fWindow + 2;
NSRect itemRect = NSMakeRect(itemPoint->x, itemPoint->y, itemSize-
>width, itemSize->height);
NSLog(@"AppController:statusItem with x = %f, y = %f, width = %f,
height = %f.", itemRect.origin.x, itemRect.origin.y,
itemRect.size.width, itemRect.size.height);
Instead of hacking pointers, you can add a one-line category method
on NSStatusItem. No subclass needed.
@interface NSStatusItem (Hack)
- (NSRect)hackFrame;
@end
@implementation NSStatusItem (Hack)
- (NSRect)hackFrame
{
return [_fWindow frame];
}
@end
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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