• 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
Re: NSStatusItem position problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSStatusItem position problem


  • Subject: Re: NSStatusItem position problem
  • From: Orr Philip <email@hidden>
  • Date: Mon, 26 Mar 2007 23:02:59 +0100

Okay then, managed to solve it through a dirty hack, but does seem to work.

I recreated the NSStatusItem interface and called it INF_StatusItem making it public so I have access to the instance variable for the window.

Then created my NSRect by first copying the pointer of my original statusItem and making it use the new interface.
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);


As I said, not the best way of doing things, but at least it works.

If anyone knows of a way to redo this code, making it simpler, then please let me know.

Philip

On 26 Mar 2007, at 21:08, Uli Kusterer wrote:

Am 26.03.2007 um 13:19 schrieb Orr Philip:
I was looking to even trying to find a way to save the current state of the NSStatusItem MenuView, insert my own NSView, that at least would allow me to use the [[[myStatusItem view] window] frame]. When finished returning the view back to the original menu again and destroying the NSView, that you would think, would be the easiest solution.

I don't quite understand what you mean. I guess if it works, you could of course just set the view and remove it again. I never tried that, so I can't tell you whether it'll work. But yeah, IMO this would be "a better solution" than my kludge with two status items.


Cheers,
-- M. Uli Kusterer
http://www.zathras.de




_______________________________________________

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


  • Follow-Ups:
    • Re: NSStatusItem position problem
      • From: Andy Lee <email@hidden>
References: 
 >NSStatusItem position problem (From: Orr Philip <email@hidden>)
 >Re: NSStatusItem position problem (From: Jake Sprouse <email@hidden>)
 >Re: NSStatusItem position problem (From: Orr Philip <email@hidden>)
 >Re: NSStatusItem position problem (From: Uli Kusterer <email@hidden>)
 >Re: NSStatusItem position problem (From: Orr Philip <email@hidden>)
 >Re: NSStatusItem position problem (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: "save as" in a document based app
  • Next by Date: Re: Connecting a custom control to manipulate NSArrayController's selection.
  • Previous by thread: Re: NSStatusItem position problem
  • Next by thread: Re: NSStatusItem position problem
  • Index(es):
    • Date
    • Thread