How to add Toolbar Button to Title Bar - macos

I have created a toolbar via IB and have a simple View menu with the "Show Toolbar" and "Customize Toolbar" menu items. Both work exactly as I would like them to.
But, I cannot seem to get the Toolbar Button to show up in the title bar of the NSWindow.
I have tried setting the "Shows Toolbar Button" in IB... no luck.
I have tried calling setShowsToolbarButton in the window controller's awakeFromNib
NSLog(#"showsToolbarButton: %#\n",[[self window]showsToolbarButton]?#"YES":#"NO");
[[self window]setShowsToolbarButton:YES];
NSLog(#"showsToolbarButton: %#\n",[[self window]showsToolbarButton]?#"YES":#"NO");
Again, no luck. Both log entries show "NO" and there is no button.
Has this feature gone away?
If not, what is the proper way to get that button to show up?
I'm building for OSX 10.6 and newer using Xcode 5.0.2 on a machine running 10.9.
Thanks for any/all insights.

The button to hide and show the toolbar was commonly seen as a small capsule button in the upper right corner at least through 10.6 Snow Leopard.
It is no longer present in standard OS X windows.
Ostensibly this is still in Xcode for supporting projects targeting older versions of OS X.
You can probably still create your own button and set its action to the same selectors, but you would likely need to create a custom window using NSBorderlessWindowMask to get the button in the title bar where it used to be.
In its place for the last several OS X versions you will find the full screen button instead.

Related

How insert full-screen button and bottom bar in interface builder mac os x and bottom bar

i can't understand how i can insert the corner top right full screen button in interface builder like this image:
and then also a bottom bar like this:
if i create a new application in Xcode the Window is this:
and there is no corner full screen button and no bottom bar...any help?
In Xcode 4.5.2 there is an option in interface builder to set this feature on (just select your window in IB, the option is named "fullscreen" in the window's attributes inspector, and is set to "unsupported" by default, just switch it on "primary window")
For the "bottom bar" ... i think it's just a NSView that is smaller than the NSWindow ^^
You should use Full Screen APIs in your NSApplication.
Go to the below link to learn how to implement this. Also be aware that this option is applicable on Mac OS 10.7.x and Mac OS 10.8.x only.
[Mac OS X 10.6.x and Xcode compatible with 10.6.x will not support this feature]
https://developer.apple.com/library/mac/#documentation/General/Conceptual/MOSXAppProgrammingGuide/FullScreenApp/FullScreenApp.html
Make sure that you have latest version of the OS and Xcode as well.
NSWindow -> size inspector -> content border

Toolbar buttons are disabled by default for Lion Cocoa app

I've created an interface nib/xib file. The app is basically working, which is cool. The standard toolbar buttons look bad, they're glossy and raised, while most apps in Lion have the flat, inner bevel look. So I created some image toolbar buttons and put them in the toolbar and they look great, but they're all disabled by default.
Is there a way to give these the correct state in InterfaceBuilder or do I have to use code to give them the proper state.
Cocoa and Objective C are very unfamiliar so it would be helpful to me if I just knew what to search for. Most of my searching brings me results for creating custom buttons for iOS.
I figured this out, here's what you do:
In the nib/xib file, double click your menu bar to show the "allowed toolbar items" sheet. From here, choose your button that you've created. In my case I'll select a back button that I want to connect to a webview control. Ctrl click + drag from the button to what you want to connect it to and then make the appropriate connection. In my case I choose goBack from the WebView.
Once it has a connection it now becomes active.

Simple Mac OS development app

What is the app's icon that appears to the right of the menu bar called?(like the twitter one)
When you press it, it's usually a drop down menu..
I want to implement a similar one in my mac app.. any help where can i start?
The menu icon is a status item, represented by the NSStatusItem class. See the question How to create a menubar application for Mac and its answers for more info.

update statusbar menu on click mac os x cocoa

I've been playing around with a statusbar menu app and what I'd like it to do is to update the content of the menu when it is clicked. I've been able to get everything working on the awakefromnib function and it works as expected. Now i just want to update the menu everytime I click on the status bar. This surely can be done, since it's done in the dropbox statusbar menu and many of the native app statusbar menus. I'm not able to associate a action directly with the click of the menu and I don't want to leave a loop running in the background cause I don't really see a need for it. Any ideas? An alternative would be to have an action associated to a menu item which does not cause the menu to get hidden again. Any help would be welcome.
Just set a delegate for your menu, and implement the -(void)menuWillOpen:(NSMenu *)menu method.

bring the application from in focus, by clicking the icon of corresponding application

I was surprised this doesn't happen automatically, but I would like my applications window to be in focus as I click its dock icon, when in minimized mode.
Just to clarify, when I minimize the app, the window goes to dock, but when I click the its corresponding Dock Icon, the window don't come in focus.
Is there anything I am missing?
I am using Qt 4.5.3 on Mac OS X 10.5, 10.6
Thanks for help.
Rahul
First answer: That's the expected behavior of a Mac app. Try Safari for example. An app can be active without showing any window. In that case, only the menu bar at the top shows that the active app is changed. So, unless absolutely necessary, you shouldn't bring the minimized window back unless the user explicitly does so. That's the Mac way!
Second answer: I understand that there are cases where you want to bring the minimized window up. In Cocoa, the application delegate method -applicationDidBicomeActive is called when the application gets the focus, and there you can bring the window up yourself. I'm sure Qt also has a similar event/callback/signal or whatever, but I don't know any Qt ... :p Sorry I can't be of any help.

Resources