What type of View is that slim bar above the editor in Xcode? - cocoa

I want to use the same sort of UI style of Xcode has right above the editor pane, as show below:
I've browsed through all the Views in Interface Builder and can't figure out what type of view this is. At this point I'm merely referring to the bar itself; not to the controls nested inside the bar, though I will be adding dropdowns in the same way as this.
What type of view should I be looking for?
TextMate uses one along the bottom of the editor too, which provides similar controls:

see:
$(DEVELOPER_ROOT)/Applications/Utilities/Accessibility Tools/Accessibility Inspector.app
just open Accessibility Inspector.app and move the cursor over the views you're interested in for details (you may need to enable accessibility options in system preferences.app).
it's also helpful to press cmd+F7 to lock onto a view and then to inspect its children.
so... 3 primary options:
1) if you want drag & drop convenience, you can simulate it with a Gradient Button
2) or you can use the button with a custom image in the button to achieve something closer
3) or just create a new view subclass and render it using a CGGradient or NSGradient

Related

Expand and Collapse Standard Cocoa Controls on a View

I want to do something similar to the calendar.app info panels, take a look at the pictures.
Here you can a see a very simple and compact info panel, but if you click on the last row "Add Notes, Attachments, or URL"....
It expands to show additional fields.
How can I achieve this functionality of expanding and collapsing additional controls ?
Can this been done through interface builder and constraints ?
Take a look at Apples example code for NSStackView,
https://developer.apple.com/library/mac/samplecode/InfoBarStackView/Introduction/Intro.html
It will show you how to implement views that collapse and disclose. In Apple's example they do everything programmatically using auto layout constraints, although you could move some of the work to IB if you wanted to.
I would create the view you want and add a tracking area to monitor when the mouse enters and clicks (using -mouseDown: notification) the "Add attachments, notes, URLs" section and use the stack view method to disclose the details.

'Embed Objects In' menu items are all disabled. How to enable?

I'm following the instructions for creating a ScrollView in the book 'Cocoa Programming for Mac OS X, 3rd Edition'. I'm using Xcode 3.2.3.
I've already created a view, into which I've drawn shapes and lines.
The next task is to convert this to a NSScrollView, which according to the book should be a simple case of selecting the existing view and choosing Layout -> Embed Objects In -> Scroll View.
However whatever object I select, the items in the 'Embed Objects In' menu are all disabled.
How can I enable the Embed Objects In -> Scroll View item?
Got it. The important thing here is not to try selecting the view in the MainMenu.xib window. Select the view in the actual document window and make sure the resize handles are visible. A little fiddly, but once you get the right object selected, then the embed objects menu items become enabled.

NSTextField with automatic NSNumberFormatter in Interface Builder

I've been making iOS apps for awhile, but I'm trying my hand at MacOS development. I'm adding an NSTextField to my UI and I noticed in Xcode that one of the options in the graphical widgets is "NSTextField with NSNumberFormatter" which implies to me that I'll be able to restrict the input of the field to numbers and configure the formatter in some way.
When I add the NSTextField with NSNumberFormatter to my UI, I can see it has a formatter outlet which appears to be kind of linked to an NSNumberFormatter (although the name is a little grayed out). However, I can't figure out any way to interact with or configure that NSNumberFormatter.
Any help?
To access the NSNumberFormatter, you have to select it in the dock (that list of objects on the left side of the XCode 4 Interface Builder [IB] window).
If the dock isn't in outline view, e.g., it just shows about 4 icons, click the triangle-in-a-square-button at the bottom of the dock. The dock should now show a "Placeholders" section and an "Objects" section; the objects are your UI objects in a hierarchical outline view.
In the IB window, click your NSTextField; that'll highlight the corresponding Text Field Cell in the outline (you may have to twiddle down some disclosure triangles to see it). The Text Field Cell should have a disclosure triangle; twiddle it down to reveal the Number Formatter. Select it, and you should now be able to manipulate it in the Inspector panel.
(There are a lot of things non-obvious like that in XCode. When in doubt, examine your UI object in the Dock's outline view, or prowl the menus with that object selected. It's amazing--and often useful--what you can discover lurking there!
to configure the number formatter, you can ( after you've selected the formatter ) open the Attributes inspector, select the behavior you want and customize the formatter. At least that worked for me in XCode 4.
– moritz

How to access an NSNumberFormatter in a text field cell?

In XCode 3.2.x's Interface Builder this was simple enough, selecting the text cell displayed a small icon for the formatter that could be selected to configure the formatter in the attributes pane.
Now in XCode 4, the formatter icon is gone! If I drag an instance of NSTextField with an NSTextFormatter from the library OR drop and NSTextFormatter into an existing cell there is no way I can figure out to select the formatter to configure it!
Add to this the fact that Core Data entities UI prototype assistant was removed and I would say IB integration into XC4 is half baked at best!
Any luck with this anyone?
you can access the formatter from the jump bar at the top of the window. if you select the component you added the formatter to, click and hold and it will turn into a drop down menu. move to the sub menu and the formatter should show up where you can select it.
it seems that you can treat the whole ui like a cascading set of menus that way.
now removing the formatter, that's a different question...
... which after further looking revealed:
over on the left side of the IB window in xcode4 is a 'dock' containing the icons for file owner, first responder etc. this column is expandable, and when you do so will show a hierarchical view of the nib file. through which you can navigate like the finder.
also, see this article:
http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/InterfaceBuilder/InterfaceBuilder.html%23//apple_ref/doc/uid/TP40010215-CH6-SW3

Sizing a control to fit its container in Interface Builder

Let's say I have a split view, and I want to fill half of it with a table view (a fairly common use case, I would think). Is there any way to tell the table view to size itself to fit the split view or do I really have to size it manually?
I've done this, the way Jon Hess mentions first. Assuming you're using Interface Builder version 3:
Drag and resize your GUI (tableview from what I understand?) component to fit into the enclosing area the way you want it.
Click it to select it.
Press Command-Shift-I to open the inspector window for this GUI component. The inspector window should now actually show that you've selected a "Scroll View".
Click the "ruler" heading to be able to set the sizing. You'll see to the right an animated representation of how your GUI component will behave within its enclosing GUI component, and to the left another represenation of the same, without animation, but with four springs and two struts that you can turn on or off.
Turn all six things on, making them red.
Voilà :-)
It's generally easier to create the subviews first, then use the Layout/Embed Objects In/Split View menu item to create the split view around them.
As far as I know, doing it manually is the only way to go. However, if you turn on "snap to cocoa guidelines", the inner view will snap to the edges of the enclosing view as you drag towards them. This makes it easier than having to manually mouse the edges into place, or manually edit the sizes to match.
You can set all of the springs and struts of the table view to "on" in the size inspector and that will cause the table view to fill the split view. Alternatively, you can use the outline view in the main document window to place the tableview's enclosing scroll view directly into the splitview instead of in an intermediary custom view.

Resources