NSStatusItem with Popover - macos

I'm trying to make a status bar app, but i'm having some problems.
How can i show a popover with a custom view after the status item is clicked?
Example code would be appreciated.

Check out Popup. It is an open source project where you can learn all about how to do this by running it and dissecting it.

Related

Bar Button Items Not Appearing When iOS Simulator Is Ran

I added 5 bar button items on my main view controller and linked them into code. I also created show segues from the bar button items to other view controllers. Although, when I run the iOS simulator none of my bar button items appear. Can someone help me?
I think you need constraints on your bottom bar, it's probably just not in the right place.
I took a look, tested some versions (you didn't make it easy) and found that if you add bar button items but don't add a toolbar there appears to be a toolbar in the storyboard but not when you run the app, nothing appears.
Instead, remove the items, add a toolbar, constrain it, then add the bar button items within it. You should have no more problems from there.
Good luck on your app! If you have any more questions, just send me a message.

Custom button not displaying in Today Extension

I have some custom buttons in my host app that I'd like to use in the Today Extension.
They work just fine in the app but do not display in the widget.
The button on the left is my custom button class, the one on the right is a UIButton. If I change it to my custom class it too disappears.
Any thoughts why this might be happening?
----------------------EDIT------------------------
Well, somehow I managed to get it to display but sometimes it's not drawing the whole button and sometimes it's drawing the button incorrectly.
Any help would be appreciated! Thanks

Xcode osx scroll view

I am going round in circles trying to get a custom view to scroll correctly.
To simplify this.
I create a new OSX cocoa application.
Go to the xib file, select the window. drag a custom view, then drag a few buttons into it.
Run the program, you have a button in the screen.
Now go back the custom view, select editor -> embed in -> Scroll view
Everything looks fine, and suggests you will have two buttons with scroll bars in the custom view.
Run the program, the custom view shows with scroll bars, but the button do not show.
What am I doing wrong?
Following your instructions I have created and changed the project. No problem.
Run in IB your "app", CMD R. The user interface itself can be checked in this way.
If problem remains
Check the layer position->Click on the custom View
Is it possible to Layout->Send to back? If yes, then your button-scrollview is not embedded.
Unembed the button, view and repeat the process, by checking in IB if now the interface shows appears correctly.

How do I add an "add" button to a tab in a uitableviewcontroller within a uitabbarcontroller?

xcode 4.6
using Storyboards
When I drag a Bar Button Item to the navigation bar at the top of one of the UITableViewControllers that are children of the UITabBarController xcode creates a new navigation bar at the bottom of the page instead of adding the button where I dropped it. I would be ok with this, but when I run the app the bottom navigation bar never shows up, so my button is never displayed.
If you need to visualize the app, picture the following: Root controller displays a list of accounts. When an account is clicked a tab controller lists tabs for opportunities and contacts. I need the ability to add opportunities and contacts from the relevant tab
Any help is greatly appreciated.
EDIT
I am not sure if this is the correct solution or not. I have embedded the uitableviewcontrollers in navigation controllers, which appears to have fixed the problem.
Follow-up question - Is this the correct way to handle this situation?
Yes, that is the correct way to handle this situation.
You should embed the view controller inside a navigation controller by clicking the view controller in your storyboard and using the Xcode menu "Editor" > "Embed In" > "Navigation Controller".

Mac OSX NSStatusItem with Custom NSMenu/MenuItems AND Drag And Drop functionality

I am trying to create a Mac Application that has an NSStatusItem icon in the Status Bar. The status bar icon should support file drag and drop and must also show a menu when clicked.
The problem is that I have managed to achieve both functionalities separately and am having a hard time merging them together.
I was able to create a Status Bar Application using this link :
http://cocoatutorial.grapewave.com/2010/01/creating-a-status-bar-application/
And then I was able to achieve drag and drop functionality on the status bar icon using the following link
Drag and Drop with NSStatusItem
The problem that I am facing is as follows, in order to get drag and drop, I have to create another view and then assign that view to the NSStatusItem as shown below :
NSStatusItem *statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
ViewWithDragFunctionality* viewWithDrag = [[ViewWithDragFunctionality alloc] initWithFrame:NSMakeRect(0, 0, 24, 24)];
[statusItem.view addSubview:viewWithDrag];
Since this is just a view, it does not, obviously, behave as the NSStatusItem's default view and does not support mouse interactions or anything else.
I managed to find a way around that by adding the following function to ViewWithDragFunctionality.m
- (void)mouseDown:(NSEvent *)theEvent {
NSLog(#"Status Bar Icon Clicked");
}
The function is called whenever the status bar icon is clicked and file drag and drop is also being detected.
But now I am stuck with figuring out how to get the menu to display when clicking the status bar icon.
Any help will be much appreciated. I am working on a solution for this and will post it here if I find something first :)
Regards
Shumais
After many days of hit and trial, looking for appropriate tutorials and banging my head against the wall to no avail, I finally stumbled across an imgur application code base generously hosted on github for the public.
The code was hosted at gihthub by a user called ZBUC.
The code that helped me out is at the following repository location on github : https://github.com/zbuc/imgurBar
This is exactly what was needed, after studying how he/they did things in there and combining what I learned/found with the links mentioned in the question, I was able to create a Custom status menu item for my application, was able to get a proper menu to drop down as is the case with a default status menu item and was also able to add drag and drop functionality to my applications status menu item.
So now I have a Custom Status Menu for my application which works like a normal status menu and also supports drag and drop functionality.
I hope that the links in the question, along with the repository link posted above, are of help to everyone who needs what I did.
Thank You
Shumais

Resources