• 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
Toolbar and custom views
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Toolbar and custom views


  • Subject: Toolbar and custom views
  • From: Kristofer Szymanski <email@hidden>
  • Date: Thu, 1 May 2003 14:49:07 +0200

Thank you very much for your help.

While I was waiting for answer to my question, I made every window
a custom view, added a toolbar to mainWindow and chaning views (like
in System Preferences"). It works great, but I have two different question
that maybe you (or someone else) could answer.

How do I change title of a main window to (example)View1 when I click
on the "View1" button and view "View1" appears ?

I know I should add something to this code ... but what :-) ?

- (IBAction)goView1:(id)sender
{
[mainWindow setContentView:blankView];
[self resizeWindowToSize:view1Size];
[mainWindow setContentView:view1];
}

I also have to left some free space in the custom views for toolbar.
This space is visble when I customize toolbar (when choose "Text only"). If I do
not have any free space the content part of the custom view is placed "under"
the toolbar. How do I avoid it ?

Thanks !

/ Kristofer


This is actually pretty painless. Back in Interface Builder, you need to
add outlets to the same class that is receiving the IBAction events that you
show in your message. Make one outlet for each of the three windows you
will be showing, and connect them to the windows in Interface Builder and
save the nib. I'll assume you'll name the variables "window1" etc.

In Project Builder, go to the .h file and add a variable within the {
braces:
NSWindow *activeWindow;

In each of the methods, you want to write the equivalent of the following
code:

- (IBAction)myWindow1:(id)sender {
// the if statement makes sure we don't close and re-open the same window
if (activeWindow != window1) {
// get rid of the current active window
[activeWindow orderOut: sender];
// reset the active window to the new one
activeWindow = window1;
// show the new active window
[activeWindow makeKeyAndOrderFront: sender;
}
}

This should manage the windows, but I've never used an NSToolbar, so I have
no experience with this. Please email me back if any of it isn't clear.

Cheers,

John



Hello,

After reading this article :

http://www.macdevcenter.com/pub/a/mac/2002/03/15/cocoa.html

i thought it would be nice to add a Toolbar to my AS app. I am not familiar
with Cocoa but I want to try using example from the article.

I already added a nice toolbar to my app, with three different buttons.
Now I have to tell the app what those buttons should do ...

I have a mainWindow (now with toolbar :-) and three other windows
(myWindow1, myWindow2, myWindow3). When I click on the button
I want to display right window and close other.

How do I write it in Cocoa ? Could someone help me define those
IB Action methods ?


// IB Action methods

- (IBAction)myWindow1:(id)sender
{


}

- (IBAction)myWindow2:(id)sender
{

}


- (IBAction)myWindow3:(id)sender
{

}

Would it be easier to move the content of each window (all items
are in tab views in every window) - all tab views - to main window
and "hide" all tab views except the one I want to show when I
click on the one of the buttons ?

/ Kristofer
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Toolbar and custom views
      • From: John Timmer <email@hidden>
  • Prev by Date: Newbie Q: error on doAlert
  • Next by Date: Re: Newbie Q: error on doAlert
  • Previous by thread: Drawing a dimmed button cell
  • Next by thread: Re: Toolbar and custom views
  • Index(es):
    • Date
    • Thread