|
|
Toolbar Questions
|
|
|
|
Junior Member
Join Date: Jul 2002
Location: Australia
Status:
Offline
|
|
How can I implement in a normal NSToolbar so when a user presses a button a new window will be attached on the toolbar and the old window will close...
like the System preferences
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Mar 2000
Location: Ithaca, NY
Status:
Offline
|
|
System Preferences doesn't create a new window when switching between preference panes. It just sets the content view of the window, using -[NSWindow setContentView:] and resizes the window to fit the new view.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
See OAPreferencesController in our open-source OmniAppKit framework for an example of how to implement a System Preferences-style toolbar and window.
And actually, if your set of views isn't dynamic (that is, it'll always be the same handful of views), it's even easier: use a tabless NSTabView for the window content, and have your toolbar item actions switch which "tab" is displayed.
(
Last edited by Rickster; Oct 11, 2002 at 04:45 PM.
)
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Jul 2002
Location: Australia
Status:
Offline
|
|
This is my ToolBar itmes action:
Code:
- (void)toolbaritemclicked:(NSToolbarItem*)item {
[MainWindow setFrame:[CustomView frame] display:YES animate:YES];
[MainWindow setContentView:CustomView];
}
It works... sorta... though when it resizes it resizes to the CustomView size.. which I want... but it resizes with the Toolbar... to the toolbar covers about a 1/4 of the CustomView..
Is there another way of doing this?
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
1) instances should start with a lowercase letter by convention: mainWindow is an instance, whereas MainWindow is a class...
2) You need to determine the height of the toolbar and include that in your rect. Sample code for doing it one way is in OmniAppKit, and Apple's recommended method is available at http://developer.apple.com/techpubs/...barHeight.html
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status:
Offline
|
|
How can I set it so that after a toolbar item is clicked it changes over into a new toolbar item, a la a "stop" button with it's own icon and action. I know how to create the two toolbar items in their entirety, it's just switching them out I'm not sure about.
Thanks
|
you are not your signature
|
|
|
|
|
|
|
|
Junior Member
Join Date: Jan 2003
Status:
Offline
|
|
NSToolbarItem has a few methods:
setImage:, setLabel:, setAction:
I would compare labels, and set things from there.
Just a thought though, instead of two actions, you might want to have just one, and when it's called, check the label of the sender.
Many ways to do this, hope this helped.
|
swont
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
It'd be better to change the icon and label of an existing ToolbarItem via validation than to switch out entire ToolbarItems -- if you do the latter, you'll likely run into problems with the toolbar saving its configuration. For example, in a hypothetical audio/video player app:
Code:
- (BOOL)validateToolbarItem:(NSToolbarItem *)item;
{
SEL action = [item action];
if (action == @selector(playPause:)) {
if ([self isPlaying]) {
[item setLabel:@"Pause"];
[item setImage:[NSImage imageNamed:@"PauseButton"]];
} else {
[item setLabel:@"Play"];
[item setImage:[NSImage imageNamed:@"PlayButton"]];
}
}
return YES; // all items always enabled for this simple example
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|