Questions tagged [nsitemprovider]

17 questions
7
votes
2 answers

How to Pass More than Just a String in NSItemProvider in SwiftUI Drag and Drop

I have reviewed some questions on Stack Overflow about drag and drop reorder with SwiftUI, and this one was particularly helpful: SwiftUI | Using onDrag and onDrop to reorder Items within one single LazyGrid? I'm looking to expand this functionality…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
4
votes
1 answer

SwiftUI: Not getting dropped NSString value in DropDelegate

I'm trying to implement a simple drag and drop with NSString. I can get this working with NSURL but not NSString. Every time I try the drag and drop I always end up with a nil value. Here is my code: struct ContentView: View { var body: some…
iphaaw
  • 6,764
  • 11
  • 58
  • 83
3
votes
1 answer

Error when reading NSAttributedString from UITextPasteItem

In order to support a custom paste behaviour, In my UITextView, which I set as its own UITextPasteDelegate in awakeFromNib(), I implemented textPasteConfigurationSupporting(_:,transform:). When pressing the paste button above the software keyboard,…
Nickkk
  • 2,261
  • 1
  • 25
  • 34
3
votes
0 answers

NSItemProvider loadObject in SwiftUI Drag and Drop

I am dragging and dropping views using a DropDelegate in SwiftUI. I'm successfully wrapping my data in an NSItemProvider using the .onDrag View Modifier, and I even have .onDrop working if I am able to have my drop data be one of the stored…
Hunter Meyer
  • 314
  • 1
  • 10
2
votes
0 answers

NSItemProvider has no registeredTypeIdentifiers during drop in SwiftUI MacOS app

Trivial example of a drop target. Running on MacOS. When you drag text content from another app (eg Notes), it is successfully targeted (ie box turns green) but no types are exposed for the actual drop. Resulting log message is: Item can't load…
Rumbles
  • 806
  • 1
  • 8
  • 15
1
vote
0 answers

SwiftUI receiving NSFilePromiseReceiver via NSItemProvider

I have a SwiftUI list that can receive dropped images. I want it to support file promises to get full-resolution images from the Photos app (on macOS, though presumably similar on iOS). Here's a simplified edition of my code for the list and…
Dejal
  • 813
  • 6
  • 18
1
vote
0 answers

How do I maintain transparency when loading WebP format images on iOS?

I have a function to import images from an array of NSItemProvider (passed from a PHPickerViewController) and I need to maintain transparency in the images. Any images in PNG format are correctly maintaining transparency but WebP images are not. The…
stackunderflow
  • 754
  • 7
  • 18
1
vote
0 answers

How to implement SwiftUI’s .onDrag modifier with NSImage (macOS)

I am building a sandboxed app for macOS with SwiftUI. I have a NSImage that is displayed as Image(nsImage: myNSImage). I want that View to support drag and drop, meaning that it can be dragged to any location that can receive image files. Here’s my…
ixany
  • 5,433
  • 9
  • 41
  • 65
1
vote
2 answers

NSItemProvider[URL] - how to COPY with drag&Drop instead of MOVE?

I have implemented function that returns NSItemProvider func dragOutsideWnd(url: URL?) -> NSItemProvider { if let url = url { TheApp.appDelegate.hideMainWnd() let provider = NSItemProvider(item: url as NSSecureCoding?,…
Andrew_STOP_RU_WAR_IN_UA
  • 9,318
  • 5
  • 65
  • 101
1
vote
0 answers

Create NSItemProvider from NSImage

Question: How to create NSItemProvider from NSImage? The image is not being shown in LPLinkView Is there any other alternate way for creating an NSItemProvider from an image on macOS? My failed attempt: Even though I managed to create the object…
user1046037
  • 16,755
  • 12
  • 92
  • 138
0
votes
1 answer

NSItemProviderWriting for dragging content to Finder

I'm building a SwiftUI view with draggable content, with a custom NSItemProviderWriting class to provide one type of data for when dragged into another part of the app, and another type of data when dragged into Finder. I'm having the hardest time…
RL2000
  • 913
  • 10
  • 20
0
votes
0 answers

SwiftUI: detect origin domain when dropped from a website

In a macOS app (target: 12.3), I support dropping images from websites. I would like to detect the domain of the website that the image was dropped from. I would show this domain in a confirmation dialog: "Are you sure you want to download this file…
bzyr
  • 289
  • 1
  • 11
0
votes
1 answer

Using TableView's Drag & Drop API with underlying value type data objects

In iOS 11 Apple introduced it's drag and drop APIs to the OS (principally to support dragging between apps on iPadOS) via the NSItemProvider class and provided a customised implementation for UITableView with the UITableViewDragDelegate and…
flanker
  • 3,840
  • 1
  • 12
  • 20
0
votes
2 answers

Getting the size of a media item given a NSItemProvider?

I'm using a PHPickerViewController to allow the user to select a media item from their library. And the specific case of interest is when they select a video. I get a callback on the PHPickerViewControllerDelegate delegate method: func picker(_…
Chris Prince
  • 7,288
  • 2
  • 48
  • 66
0
votes
1 answer

Custom Data Not Working with itemProvider for Drag/Drop Collection View Functionality - Swift

I have a collection view that displays data arranged in a custom data model (struct) called "claimData." claimData declaration: struct claimData { var image = UIImage() var imageTitle = String() var hasCustomDescription = Bool() var…
Christian W
  • 353
  • 2
  • 12
1
2