Re: Cocoa-dev Digest, Vol 4, Issue 303
Re: Cocoa-dev Digest, Vol 4, Issue 303
- Subject: Re: Cocoa-dev Digest, Vol 4, Issue 303
- From: Orr Philip <email@hidden>
- Date: Tue, 27 Mar 2007 07:47:37 +0100
Hi there Andy and interesting though I don't seem to be able to get
it to work.
Both the _fWindow and _frame are private instance variables and I
think it's that that's throwing the code off. Or maybe it's just me
calling it wrong.
How would you use your routine as it does seem a lot easier to
implement than bashing pointers.
Philip
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
_______________________________________________
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