• 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
NSView in NSToolbar moves upward
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSView in NSToolbar moves upward


  • Subject: NSView in NSToolbar moves upward
  • From: Marcus Karlsson <email@hidden>
  • Date: Sun, 10 Jun 2007 01:40:11 +0200

Hi.

I'm working on a Cocoa application with a toolbar. The toolbar has three buttons and a NSView containing a NSPopUpButton. When I click on the upper right hide/show button and simultaneously press the apple button I can switch between different toolbar configurations. But after a couple of clicks the NSPopUpButton start to move upwards. I captured it in a movie: http://www.aletes.se/public/toolbar- problem.mov

Why does that happen and what should I do to prevent it?

The view is 315 x 32 pixels in size.

This is the code controlling the toolbar:

/* toolbar settings */
- (void)setupToolbar
{
/* Create toolbar */
NSToolbar * toolbar = [[NSToolbar alloc] initWithIdentifier:@"mainToolbar"];
[toolbar autorelease];
[toolbar setDelegate:self];

/* Set toolbar settings */
[toolbar setAllowsUserCustomization:YES];
[toolbar setAutosavesConfiguration:NO];
[toolbar setDisplayMode: NSToolbarDisplayModeIconOnly];

/* Assign toolbar to window */
[window setToolbar:toolbar];
}


- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
itemForItemIdentifier:(NSString *)itemIdentifier
willBeInsertedIntoToolbar:(BOOL)flag
{
NSToolbarItem *item = [ [ NSToolbarItem alloc ] initWithItemIdentifier: itemIdentifier ];

/* Toolbar item: Add */
if ( [ itemIdentifier isEqualToString: @"Add" ] )
{
[ item setLabel: NSLocalizedString( @"Add", nil ) ];
[ item setPaletteLabel: [ item label ] ];
[ item setImage: [ NSImage imageNamed: @"add.png" ] ];
[ item setTarget: self ];
[ item setAction: @selector( addNote: ) ];
}
/* Toolbar item: Remove */
else if ( [ itemIdentifier isEqualToString: @"Remove" ] )
{
[ item setLabel: NSLocalizedString( @"Remove", nil ) ];
[ item setPaletteLabel: [ item label ] ];
[ item setImage: [ NSImage imageNamed: @"remove.png" ] ];
[ item setTarget: self ];
[ item setAction: @selector( removeNote: ) ];
}
/* Toolbar item: List view */
else if ( [ itemIdentifier isEqualToString: @"ListView" ] )
{
[ item setLabel: NSLocalizedString( @"Notes", nil ) ];
[ item setPaletteLabel: [ item label ] ];
[ item setView:listView ];
[ item setMinSize:NSMakeSize(100,NSHeight([listView frame]))];
[ item setMaxSize:NSMakeSize(40000,NSHeight([listView frame]))];
}

return [ item autorelease ];
}


/* List of availible toolbar items */
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
{
	return [NSArray arrayWithObjects:
		@"ListView",
		@"Add",
		@"Remove",
        NSToolbarPrintItemIdentifier,
        NSToolbarCustomizeToolbarItemIdentifier,
        NSToolbarFlexibleSpaceItemIdentifier,
        NSToolbarSpaceItemIdentifier,
        NSToolbarSeparatorItemIdentifier, nil];
}

/* List of default toolbar items */
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar
{
    return [NSArray arrayWithObjects:
		@"Add",
        @"Remove",
		@"ListView",
		NSToolbarPrintItemIdentifier, nil];
}


Thanks.

Marcus



_______________________________________________

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: NSView in NSToolbar moves upward
      • From: Seth Willits <email@hidden>
  • Prev by Date: Re: programmatically adding model objects to NSOultineView/NSTreeController
  • Next by Date: Re: NSView in NSToolbar moves upward
  • Previous by thread: Re: NSImage problems
  • Next by thread: Re: NSView in NSToolbar moves upward
  • Index(es):
    • Date
    • Thread