add a custom view/windows in the mac os X dock - cocoa

I would like to add a custom view (a pager) in the dock, just before the trash and was wondering on how to perform a such task.
Do you have any pointer to help me to start?
Thanks in advance for your help :)
regards,

Take a look at the NSDockTile class, and specifically the contentView property. You access this through NSApplication's dockTile accessor. You can set a custom view to display in the dock. Keep in mind, though, that the user can make the dock very small, so you can't assume your icon will be at any particular size.
The Dock Tile Programming Guide has some pointers to get you started.

Related

Why is the titlebar overlapping view controller content?

Can anyone tell me why this is happening and how can I fix this? I thought the content is suppose to display after the titlebar, not under it. The only way for me to fix this is to create a new project.
The Button on top is being overlapped by the titlebar. Not sure how that became possible. There's a lot of room for the window to adjust the view controller but not sure why it's not doing that.
Check window properties. You might have enabled “Full Size Content View” property.

Add an NSView around cursor?

Simple question, starting out with macOS stuff – I’d like to create a small radial menu around my cursor, top-most, above whatever application is currently active, whenever a specific mouse button is pressed.
I have the specific mouse button over all application down, but I’m wondering where I need to draw that NSView, i.e. “topmost”. I guess on iOS this would be at the UIWindow level, but would NSWindow be the wrong approach here?
this is purely an opinion-based question, but basically if you want to present any custom content on the desktop, that should use NSWindow, and you can customise the window's content for your wish.
NOTE: you can find more information about the NSWindow class in Apple's Class Reference Docs.

Can I change NSScreen visibleframe?

I trying to create a toolbar that docks on the top of the screen below the OS X menu bar.
I would like no other application's to be able to overlap my application when they are maximized. I can get the visible frame dimensions using NSScreen's visibleframe method, but can I adjust the visibleframe to omit the size and position of my application?
The simple answer is that no, you can't. I think that the only way to change the screen's visibleRect would be to inject code into AppKit and swizzle the method.
Even then, it might not do what you want because that method might not be what Apple uses to determine the "safe area" for windows and almost certainly would not work with Carbon apps.
Nothing you do with window levels will change this.
What you could do is use the Accessibility framework to reposition windows if you detect that their frames have changed such that they overlap your toolbar window. Unfortunately, I think you might need use polling for this.
Try setting your window's level to NSDockWindowLevel.
This may not work, depending on whether the system subtracts all windows on that level or only ever the Dock's window, but it's worth a try.

IB builder or programmatically draw?

What do you advise? should I programmatically draw my textfields, labels, images or should I use IB?
Would it make any difference? I have scrolling issues (bit jerky) but not something I cannot live without!
I would use IB to help maintain the app. Jerky performance is usually a result to memory management issues and not specific to IB. IB just does the object creation and sets common properties, so do it in code, or in IB the end result is the creation of objects and setting of properties.
ok. problem solved. you were right and wrong regarding the IB...
to explain myself:
I was loading my cell from a nib file.
The trick and thanks goes to this site: http://iphoneincubator.com/blog/tag/dequeuereusablecellwithidentifier
i forgot to set my cell identifier to the nib file so i was creating the cells every time they were scrolled off the screen!
so tip!
When you load from nib ALWAYS put the right identifier in the "identifier" place!!!
thanks to nolimitsdude who actually pointed to the right way!!

NSLevelIndicator - Cocoa

How would I be able to use a NSLevelIndicator? I am very new to this so, I don't know much on how to use a progress bar for my application.
You wouldn't use NSLevelIndicator for a progress bar. Check out NSProgressIndicator instead. It does both progress bars and "spinner" controls. NSLevelIndicator is used, for example, to show how full a disk is, or how much battery life is left in your wireless mouse.
You don't explain your level of experience. Assuming you have a window already created in Interface Builder, drag an NSLevelIndicator onto the window, create an outlet to it in your application, and set its value as needed. If you don't understand any of that, follow Apple's standard beginners' tutorial and start from there.
How would I be able to use a NSLevelIndicator?
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSLevelIndicator_Class/
how would I use a NSProgressIndicator?
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSProgressIndicator_Class/

Resources