[GH-ISSUE #298] Fixing macos clipboard issues #95

Closed
opened 2026-05-05 03:39:28 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @daansystems on GitHub (Sep 16, 2025).
Original GitHub issue: https://github.com/ultimatepp/ultimatepp/issues/298

Drag & Drop files doesn't seem to work well on Macos. There are a few issues here:

2aa9f2a820/uppsrc/CtrlCore/CocoClip.mm (L58)

Doesn't work for files, it will use Upp::ToString(type) to convert the type to the string "NSFilenamesPboardType" which should be "files".
I think all the types should be defined here:

Upp::String fmt = [type isEqualTo:NSPasteboardTypePNG] ? "png" :
	                  [type isEqualTo:NSPasteboardTypeRTF] ? "rtf" :
					  [type isEqualTo:NSFilenamesPboardType] ? "files" :
...etc...
	                                                          Upp::ToString(type);

This will solve the internal dragging of files for an ArrayCtrl, and the commented out code here will work again with a small fix:

2aa9f2a820/uppsrc/CtrlCore/CocoClip.mm (L378)

The:

"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"

needs escaping for the two " there:

"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"

This doesn't solve dragging from an U++ ArrayCtrl to Finder yet, trying to fix that too.
Cheers.

Originally created by @daansystems on GitHub (Sep 16, 2025). Original GitHub issue: https://github.com/ultimatepp/ultimatepp/issues/298 Drag & Drop files doesn't seem to work well on Macos. There are a few issues here: https://github.com/ultimatepp/ultimatepp/blob/2aa9f2a820ed21c1b627a77ee7f928f13961af5a/uppsrc/CtrlCore/CocoClip.mm#L58 Doesn't work for files, it will use Upp::ToString(type) to convert the type to the string "NSFilenamesPboardType" which should be "files". I think all the types should be defined here: ``` Upp::String fmt = [type isEqualTo:NSPasteboardTypePNG] ? "png" : [type isEqualTo:NSPasteboardTypeRTF] ? "rtf" : [type isEqualTo:NSFilenamesPboardType] ? "files" : ...etc... Upp::ToString(type); ``` This will solve the internal dragging of files for an ArrayCtrl, and the commented out code here will work again with a small fix: https://github.com/ultimatepp/ultimatepp/blob/2aa9f2a820ed21c1b627a77ee7f928f13961af5a/uppsrc/CtrlCore/CocoClip.mm#L378 The: `"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"` needs escaping for the two " there: `"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"` This doesn't solve dragging from an U++ ArrayCtrl to Finder yet, trying to fix that too. Cheers.
Author
Owner

@klugier commented on GitHub (Sep 19, 2025):

Your changes might be a good addition to our framework. Please prepare PR to fixes you did so far.

<!-- gh-comment-id:3311152217 --> @klugier commented on GitHub (Sep 19, 2025): Your changes might be a good addition to our framework. Please prepare PR to fixes you did so far.
Author
Owner

@mirek-fidler commented on GitHub (Sep 19, 2025):

Well, let me know you I have noticed this, good work, PR not necessarry for now, I am sort of waiting whether you manage "to Finder" problem...

BTW, if you are interested in MacOS, that is great as I usually get to it last (after Win32 and Linux). If you wanted another problem to play with, we are now adding title-less window support

Image

and I am sorely missing macos implementation yet...

<!-- gh-comment-id:3311390506 --> @mirek-fidler commented on GitHub (Sep 19, 2025): Well, let me know you I have noticed this, good work, PR not necessarry for now, I am sort of waiting whether you manage "to Finder" problem... BTW, if you are interested in MacOS, that is great as I usually get to it last (after Win32 and Linux). If you wanted another problem to play with, we are now adding title-less window support <img width="2292" height="1142" alt="Image" src="https://github.com/user-attachments/assets/383a9057-7b50-4679-83cc-5ce985d177cb" /> and I am sorely missing macos implementation yet...
Author
Owner

@daansystems commented on GitHub (Sep 30, 2025):

I made a little patch that makes dragging files work to Finder, but it's not tested for other clipboard types. The MacOS code for handling dragging and the clipboard is using a lot of deprecated calls and should probably be rewritten using beginDraggingSessionWithItems:event:source:

cococlip.patch

<!-- gh-comment-id:3350033291 --> @daansystems commented on GitHub (Sep 30, 2025): I made a little patch that makes dragging files work to Finder, but it's not tested for other clipboard types. The MacOS code for handling dragging and the clipboard is using a lot of deprecated calls and should probably be rewritten using beginDraggingSessionWithItems:event:source: [cococlip.patch](https://github.com/user-attachments/files/22611368/cococlip.patch)
Author
Owner

@klugier commented on GitHub (Jan 17, 2026):

FYI @daansystems, This PR #350 (CtrlCore: Implemented drop operation for files in Cocoa.) is addressing this issue. After this changes reference/DropFiles works like a charm on macOS.

Moreover, https://github.com/ultimatepp/ultimatepp/pull/347 has been merged to address all warnings related to usage of depricated API in our pasteboard code. So, on the latest master the compilation should be smooth and without any warnings.

<!-- gh-comment-id:3764451866 --> @klugier commented on GitHub (Jan 17, 2026): FYI @daansystems, This PR #350 (CtrlCore: Implemented drop operation for files in Cocoa.) is addressing this issue. After this changes reference/DropFiles works like a charm on macOS. Moreover, https://github.com/ultimatepp/ultimatepp/pull/347 has been merged to address all warnings related to usage of depricated API in our pasteboard code. So, on the latest master the compilation should be smooth and without any warnings.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/ultimatepp#95
No description provided.