• 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: nstoolbaritem coordinates?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nstoolbaritem coordinates?


  • Subject: Re: nstoolbaritem coordinates?
  • From: Luc Vandal <email@hidden>
  • Date: Fri, 19 Aug 2005 11:57:12 -0400

Hi,

I'm not sure I'm following you. Don't I need to know what the coordinates for the item are before setting the view? Or maybe it's me that is doing something wrong. Here's the complete code:

NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];

if ([itemIdent isEqual: OpenBookItemIdentifier])
{
view = [[VRToolbarItemView alloc] initWithFrame:NSMakeRect (0,0,30,30)];


NSTrackingRectTag tag = [view addTrackingRect:[view frame] owner:view userData:nil assumeInside:NO];
[toolbarItem setTarget: view];
[toolbarItem setView:view];
[toolbarItem setMinSize:NSMakeSize( 30, 30 )];
[toolbarItem setMaxSize:NSMakeSize( 30, 30 )];
[toolbarItem setImage:[NSImage imageNamed: @"NSApplicationIcon"]];
}


I do get notified but the tracking rect is nowhere near the toolbar item!

Luc



On 19-Aug-05, at 11:22 AM, j o a r wrote:


On 19 aug 2005, at 17.17, Luc Vandal wrote:


I'm creating some custom nstoolbaritem with a view attached so that I can be notified when the mouse is over a particular item. The problem that I have right now is that I can't find how to get the coordinates (rect or frame) for a toolbar item so how can I know where to initialize the view?

Here's the code that I'm using now. It works but the frame does not correspond to the toolbar item since I don't know how to get it:


If it's an item with a flexible width I would suggest that you set the initial size to be the minimum size that you allow for that toolbar item. Once it's inserted in the toolbar it will be resized to the appropriate size for the current window by the toolbar, so that's not something you need to worry about.


If it's not a flexible-size item, then you don't have a problem - as the size of the view governs the size of the toolbar item, not the other way around.

j o a r





_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: nstoolbaritem coordinates?
      • From: j o a r <email@hidden>
References: 
 >nstoolbaritem coordinates? (From: Luc Vandal <email@hidden>)
 >Re: nstoolbaritem coordinates? (From: j o a r <email@hidden>)

  • Prev by Date: Re: nstoolbaritem coordinates?
  • Next by Date: Problem with starting up by dbl-clking a document
  • Previous by thread: Re: nstoolbaritem coordinates?
  • Next by thread: Re: nstoolbaritem coordinates?
  • Index(es):
    • Date
    • Thread