views:

220

answers:

2

I have the following code:

AXWindowController *controller = [[AXWindowController alloc] 
initWithWindowNibName:@"ActivateWindow"];
[controller showWindow:nil];

How do I use controller to make changes to the window ActivateWindow (eg. changing text on the window, etc.)? Step by step instructions would be appreciated. Thanks!

+2  A: 

Well, none of the actual window elements are handled in your piece of code, your code just initializes and shows the window. (I've just had a quick scan through, so I'm assuming that it works)

If you want to, for example, display text in a window, the simplest way is to use an NSTextField.

Very simple instructions:

  1. Drag and drop a Label item from the Interface Builder library into your window.
  2. Drag and drop a button item from the Interface Builder library into your window.
  3. In XCode, in your window controller, create an IBOutlet for your label, e.g. messageLabel
  4. In XCode, in your window controller, create an IBAction for your label, e.g. changeLabel
  5. In Interface Builder, drag and drop an "object" into your document. (Shortcut = CMD + 0)
  6. Under the Identity tab, change the class to AXWindowController. (Shortcut = CMD + 6)
  7. Ctrl + drag from the object to the label, choose the outlet messageLabel.
  8. Ctrl + drag from the button to the object, choose changeLabel.

Now, to display text when you press the button, you would add code to the changeLabel IBAction to do so. e.g. [messageLabel setTitleWithMnemonic:@"blah"];

And Finally, if you want it to automatically display text, you might as well just change the label content in Interface Builder / place the code in the windowDidLoad method in your controller.

That to me is pretty much the simplest way for you to do it. However, I recommend you read some books / tutorials on Cocoa and Objective-C before delving into harder stuff.

Michael
A: 

You'd programmatically make changes to your window in the code for your window controller, of course. Open AXWindowController.m and do whatever it is you're wanting to do. It's hard to give a more definite answer without knowing exactly what you're trying to do (if you just want to create the interface, use Interface Builder) or what your experience level is.

Preston