Mac Catalyst Make Text in UICollectionViewCell configured with UIListContentConfiguration selectable with mouse/trackpad?

I have a UICollectionView in the list style. I have cells that use   UIListContentConfiguration. All this is set up in the normal way:

UIListContentConfiguration *contentConfig = cell.defaultContentConfiguration;
     contentConfig.text = @"Bla text";
cell.contentConfiguration = contentConfig;

But I can't figure out how to make the text selectable on Mac Catalyst with the mouse? On iOS this is okay (though selectable text would be nice there too) but on Mac users would really expect the text to be selectable in this area of my app's UI. Is there anyway to configure this?

UIListContentConfiguration does not currently support selectable text (and neither do the built-in textLabel/detailTextLabel on UITableViewCell which have been superseded by the modern UIListContentConfiguration API).

If you want to provide that functionality, you will need to implement a custom cell. The best approach would be to leverage the UIHostingConfiguration API to embed SwiftUI directly in your cell, using the .textSelection(.enabled) modifier to make Text selectable. But you could also build a custom cell using a UITextField or UITextView in UIKit alone.

Yikes, having to throw away my existing cells for such a basic feature is kind of a disappointment and I'm wondering if choosing Mac Catalyst over AppKit was a good choice since I have to roll out a lot of my own stuff to get the behavior you'd expect on a desktop app in many places, and also have to resort to some hacks. I do appreciate your reply though.

None of the options here are particularly good. Going through your suggestions, I tried making a UITextField look like a label (since that suggestion seemed like the easiest way to achieve the behavior I'm after) but I just couldn't get it to work. I had a UITextField looking like a label by setting it to have no border style and an attributed string that wraps words (I need multiline support too). That looked okay, but couldn't figure out how to make the UITextField "selectable" but not "editable." If I set enabled to NO the text field wouldn't be selectable or editable.
If I left the UITextField enabled and tried to suppress editing via the delegate methods, a multiline UITextField would then render the string on a single line when it gets focus (snapping a multiline string to 1 line during text selection isn't going to work). Maybe there is a way to do it with UITextField but I couldn't figure it out....

The thought of using UITextViews and making them look like labels was something I wasn't really willing to try since UITextView is pretty heavyweight. I'm sure it's possible but I wasn't going to go down that road. I need like 20 or so of these "labels" in this UI and these are self sizing cells some with "side by side" text and the window is resizable and the thought of trying to dumb down UITextViews to behave like labels was giving me nightmares. A few years ago I tried putting non editable UITextViews in a UITableView with disastrous results. Maybe it's not that hard though. I didn't really feel like trying it.

Embedding SwiftUI is not something I'm going to do here. This view controller is in Objective-C and I don't believe you can use UIHostingConfiguration from Objective-C (at least not easily). I'm definitely not trying to throw out the entire view controller, rewriting the whole thing in Swift with the only tangible benefit being text selection.

So I ended up dropping down to TextKit and wrote my own. Not really fun having to spend so much on a feature that desktop platforms typically give us for free. I hope Catalyst will add support for selectable labels in the future since it really is a must have for many Desktop apps.

Now I just have to hack my way into NSColor.selectedTextBackgroundColor from the Mac Catalyst environment.... I think Catalyst would be a lot more useful if more of the AppKit APIs were exposed so developers could fallback to it when needed. Support for allowing developers to embed AppKit views in a view hierarchy would be nice too. I could have just embedded a NSTextField instead of a UILabel and been on my way.

Mac Catalyst Make Text in UICollectionViewCell configured with UIListContentConfiguration selectable with mouse/trackpad?
 
 
Q