• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSStatusItem position problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSStatusItem position problem


  • Subject: NSStatusItem position problem
  • From: Orr Philip <email@hidden>
  • Date: Tue, 27 Mar 2007 09:10:38 +0100

Okay, okay then it was me that was at fault.

Yup, it works wonderfully and doesn't need pointer bashing, and in just one line, I thank you.

	NSRect myRect = [statusItem hackFrame];

It's so simple, have to remember that in future uses.
Thank you once again.

Philip

On 27 Mar 2007, at 07:47, Orr Philip wrote:

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


References: 
 >Re: Cocoa-dev Digest, Vol 4, Issue 303 (From: Orr Philip <email@hidden>)

  • Prev by Date: RSS Cocoa class
  • Next by Date: Re: RSS Cocoa class
  • Previous by thread: Re: Cocoa-dev Digest, Vol 4, Issue 303
  • Next by thread: RSS Cocoa class
  • Index(es):
    • Date
    • Thread