Programmatically Show Document Name Popover for Document-Based App - objective-c

We have a custom window and titlebar for a document-based app, and we would like to support the document name popover (in Yosemite) with the standard disclosure button that appears beside the document title. Here is an image of the disclosure button and the popover when it is clicked (from TextEdit):
Is there a way to programmatically show this document name popover for a custom disclosure button?

It appears the answer to this question is: you can't - without getting into private APIs.

Related

How to display show/Hide button in highlight regular mode of NSOutlineView?

How to display show/Hide button in highlight regular mode of NSOutlineView?
I have a grop item at the top of NSOutlineview. I try to display show/hide button in that group item, but I can't find any method to do it. The source list mode can display it but regular mode doesn't.
Is it possible to display show/hide button in highlight regular mode of NSOutlineview?
thanks for helping
This behavior is specific to the source list appearance. There is no public API for getting around this, as it's an intentional enforcement (on Apple's part) of standardized appearances. You could dig around in the headers to look for a way to "hotwire" things, but use of private API bars you from distributing your app through the App Store.
The easier (non-private-API-using) route is to create your own cell view with a borderless button with show/hide title. Use a mouse tracking area (see NSTrackingArea) on the cell view (the superview of your button) to set the button's alpha (via its animator) to fade the button in/out on mouse in/out. Your button would tell the outline view to expand/collapse its cell view's represented item (the easiest way would be to define an outlet to the button via your custom NSView cell view class and configure the button's target/action when the cell view is created for the item).

how to align text center in nsMenuItem Cocoa Mac osx

I am new in MAC OS X development, I have to align text centre in nsMenuItem but I not find any particular solution. I checked on google but not find any tutorial.
Find some tutorial but not exactly same, in these tutorial we take a NSView in nsMenuItem and then Insert subview in NSVIEW to accomplish it centre align.
Is there is any better solution? Please provide me link if possible.
Edit : I attached screen shot, but this is not working for me.
Thanks
You can set the Attributed String of the menu item, which does allow you to center the text, as well as change the font, color and size of the text as well.
I do not know which version of Xcode/OSX you are using, but under Xcode 5.0.2 you can use the built-in interface builder to edit the attributed strings of menu items.
Click the MainMenu.xib entry, then click the menu you want to edit to open it, then click the menu entry. On the right side of the window there should be some options, if not click the right most square in the group of 3 at the top right of the Xcode window 1.
Once you have the right panel open click the Attributes Inspector icon [2] (4th from the left, looks like a slider type icon). At the bottom of the list of attributes you will see an entry for "Attrib. Title" [3].
That is where you can set a custom font, color and alignment for your menu item.
If you need more control then that provides, you can also embed custom NSViews into your menus which gives you complete control over how the menu will look.

Xcode Interface Builder set highlighted image for button

I'm making an cocoa application from Mac OS X, not for iphone.
I am able to set the background image of a button and uncheck bordered in the attribute inspector. However, I do not know how I set the image for when you click on it (highlighted/on click, whatever you want to call it). I want to do this because
I have found guides on google to do this with UIbutton but this isn't helpful since I'm making this for Mac.
I am using InAppStoreWindow and the button is in the Title bar. When I click on the button with the custom image, the background goes white:
Thank you very much!
You are getting white background when button is clicked because You're using incorrect type. You need to change button's type to Momentary Change. You can change it in Attributes inspector:
Or change programatically:
[buttonOutlet setButtonType:NSMomentaryChangeButton];
And for highlighting: just add another image as alternate image in Attributes Inspector and it will be shown when button pressed.

Objective-C: How to create a Menu with custom UI?

I'm trying to develop an application in Xcode 4.1. I would like to create an application located in the menu bar, like described in this tutorial:
http://cocoatutorial.grapewave.com/2010/01/creating-a-status-bar-application/
But instead of showing a standard Menu when clicking, I would like to show a more graphical UI with some text fields, buttons, etc. like they do in Fantastical:
http://flexibits.com/fantastical
I hope someone can tell me, how I can do.
Here's the Status Bar Programming Topics guide.
Make an NSStatusItem. Set the item's view to a custom view that you create. This view will appear in the status bar and receive mouse clicks.
Make your custom view handle a mouse click by presenting a window with your custom UI.
It's not necessary to use a custom view. All you have to do is set the status item's target & action to your method which shows the window:
[self.statusItem setTarget:self];
[self.statusItem setAction:#selector(ShowOrHideWindow:)];

Overlapping images in cocoa touch applications

I programatically created a box. It can be moved around the screen. The problem is that there are buttons on the screen I made in Interface Builder. When the box moves over a button, it covers the button. How can I make it appear behind the button?
When you add your box to the view, instead of using [view addSubview:box] use [view insertSubview:box atIndex:0].