How can I Display an NSTextField or an NSProgressIndicator within an NSMenu? I'm looking to do something similar to the Spotlight icon menu, or the Help menu of most applications.
You can use the [NSMenu - setView:] method for it. But you can't add an NSTextField without major hacks. Apple still uses a brain dead Carbon implementation for menus. If you want keystrokes you have to go down into Carbon and do some magic for key handling.
Its so worse you will not even get a menu action fired if the user selects the menu item with the return key.
For this reason the official Apple sample just shows a slider as an embedded menu.
Please raise this topic on the official apple mailing list so Apple can see that this is a wanted feature and will be fixed soon.
Related
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
I really dig the way Tictoc anchors to its toolbar item but I'm not sure which APIs I should be learning to replicate that feature. The two things I'm hoping to learn are:
Adding an item to the system menu bar
Anchoring my window to the menu bar
Here's a screenshot for anyone who hasn't had a chance to use this app:
To add an item to the menu bar, check out NSStatusItem.
There are a few options for windows resembling the one in your screenshot, but I recommend Matt Gemmell's MAAttachedWindow. There's a link to it here, including a project which does the NSStatusItem thing.
I'm currently working on my first iOS application to run on the iPad, and I've come across a problem. I have been asked to implement menu's similar to the ones in the default applications such as when you click on the "Calendars" button in the top left of the calendars app.
Only issue is, I cant seem to find a standard UI object that looks like these, with the arrow connecting the menu to the button etc. Is this a standard UI component that I should be able to use, or will I have to imitate them by creating a custom object?
Thanks for any help.
That is a UIPopoverController. There isn't an Interface Builder control for this. You need to create one programmatically:
UIPopoverController *popover = [[UIPopoverController alloc]initWithContentViewController:someTableViewController];
See the documentation for more information and sample projects, specifically ToolbarSearch:
How could I make an NSWindow's title bar look like that of the Mac App Store or of the app Feeder where it's height is increased and other controls are show in it.
To see what I mean just check out the website for the Mac App Store : http://www.apple.com/mac/app-store/.
Is it a custom NSWindow or is it a completely borderless window with an NSView made to look like the title bar?
https://github.com/indragiek/INAppStoreWindow
Title bar and traffic light customization for NSWindow
INAppStoreWindow is an NSWindow subclass that was originally developed to mimic the appearance of the main window in the Mac App Store application introduced in OS X 10.6.6.
The MAS application has since transitioned away from this design, but INAppStoreWindow is still being actively developed to provide extensive additional customization options for NSWindow title bars...
For iTunes (v9.x) Apple used no toolbar, but custom aligned icons and controls in the top bar, to achieve a similar effect. (see link below)
The window looks like a "textured & unified title and toolbar" window to me. (or a slight variant of such)
To reposition the traffic light buttons follow my answer to this question.
However, as Dave DeLong already (similarly) commented: "The UI is terrible. Please don't even think about it."
You can also take a look at http://orestis.gr/blog/2007/09/24/messing-with-windows/ . This uses some undocumented stuff, though, so it won't actually get approved FOR the App Store.
In Windows 7, the explorer shows a scroll tip in detailed view like this:
alt text http://i.msdn.microsoft.com/Dd378445.scrolltip%28en-us,VS.85%29.jpg
This image is taken from this MSDN page, but there's no information there on how to activate this for a plain list control.
I'd like to get my list controls to do the same, but I can't figure out how to do this.
There's the LVN_BEGINSCROLL and the LVN_ENDSCROLL notification message, but no LVN_SCROLL message which is sent while scrolling so I could implement my own scroll tip and updating it while scrolling.
I haven't found any window styles or settings for the list control to activate this feature either.
But since Windows 7 can do this, it must be possible somehow. Anyone got an idea how I could implement/activate this feature?
You could probably subclass the listview and catch WM_VSCROLL
A somewhat related article in MSJ implemented "scroll tips" and deferred scrolling