NSPasteboardType of dragged keychain item - cocoa

I want to create an NSView which will accept dragged items from the KeychainAccess app (for example a certificate).
Dragging a certificate to the desktop results in a file, so I think it should be possible to receive them in my NSView as well. I know the basic concept of drag and drop in Cocoa and searched / tried a lot already, but I really don't know how to achieve this.
Any help would be appreciated!
Jodocus

Related

NSSearchField with Suggestions view underneath like Spotlight MacOS cocoa Swift 4.2

I want to write a MacOS Cocoa Desktop App with XCode 10 and Swift 4.2.
It should have a searchfield with a suggestions view opening as you keep typing like Google Search or Spotlight with autocompletion.
However I'm completely new to Cocoa programming.
I have already tried to add an NSSearchField and a dynamically added NSPopOver object with subclass of NSTableView which contains all the suggestions. But I am not happy with the suggestions view because of the anchor/arrow that appears with it. It seems like it breaks the UI guidelines.
Thus I have tried to implement my own custom subclass of NSView containing the suggestions. It works fine but I struggle with simple things like making it hide/disappear as soon as any other area is clicked in the app.
Does anyone know a good example as best practice for this task or have some sample code?

Override window drop in Cocoa

I'm looking for a way to customize the drag/drop of windows/tabs. I have a document based app, with a custom window controller. I am able to create tabs for it and have them all along the top, they all show, everything works great with that.
Where I'm running into trouble is if I create a different unconnected windows and start trying to drag windows or tabs into different windows or tab bars to have it dock or merge. Sometimes it works how I want, sometimes it doesn't allow docking or anything. Other times it does what I don't want it to do. I need a way to help it along...
I'm looking for a way to tie into those events but in all my searching I can't find what api or where it is that is controlling the window drags/drops. I looked into the NSDraggingDestination but that has nothing relating to windows, just pasteboard stuff. Looked at NSWindowController and didn't see anything there either. Anyone know if this is possible?

Source application for dock drag and drop osx

After many hours searching for a solution to this I'm still stuck, I would be very grateful for your help.
Here is my situation: I would like to know the source application for the (drag and ) drop of a document/file on my app's dock icon (it accepts anything as specified in the .plist). In fact the final goal is to know the url of the dropped document/file if it's a browser drop. For now, knowing the application name should be enough. I simply cannot manage to get the source for a drop, it cannot reliably be found/deduced from the Drag Clipboard as it seems that some applications do not use this (such as Chrome).
Does anyone have a clue about this?
Thank you,
chocozor.
If you're dropping file icons on your app icon in the doc, have you tried the
application:openfile:
or
application:openfiles:
methods in your app delegate?
NSApplicationDelegate documentation: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSApplicationDelegate_Protocol/Reference/Reference.html

Disable All Interaction with a Cocoa WebView

I'm having difficulty in using a WebView that is being used purely to display a preview of a website - and I want to ignore all/any interactions the user may try to make with it.
I've already tried Cocoa webView - Disable all interaction to no avail; you can still easily spam-click and it will recognise the presses. (at least there's no context menu)
This one seems overkill; Disable a WebKit WebView - there must be an easier way.
In iOS I know exactly how to solve this, but as a Cocoa newcomer I am stumped - does anyone have any suggestions or better ways to achieve this? Or dump a transparent NSView on top and gobble up interactions? (tried this as well by subclassing an NSView, also to no effect)
Whole project is in IB currently, if this makes any difference.
I think you want to implement a WebPolicy Delegate and have it deny navigation events.

Drop down menu like the default iPad application menus

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:

Resources