Fix: GHOST: Accept dropped text with only CF_UNICODETEXT format present

Check for both `CF_TEXT` and `CF_UNICODETEXT` in
`GHOST_DropTargetWin32::getGhostType` because, unlike for the clipboard,
Windows does not synthesize `CF_TEXT` from `CF_UNICODETEXT` and vice
versa for drag and drop operations. Since `getGhostData` already
supports `CF_UNICODETEXT`, this is all that's necessary to make it work.

I encountered this issue when trying to drag text from Notepad++ into
Blender's text editor.

Pull Request: https://projects.blender.org/blender/blender/pulls/138524
This commit is contained in:
Jorn Visser
2025-05-07 00:53:52 +02:00
committed by Jesse Yurkovich
parent e1cd8c322a
commit d73950790c

View File

@@ -169,9 +169,14 @@ GHOST_TDragnDropTypes GHOST_DropTargetWin32::getGhostType(IDataObject *p_data_ob
}
/* Text
* NOTE: Unicode text is available as CF_TEXT too, the system can do the
* conversion, but we do the conversion our self with #WC_NO_BEST_FIT_CHARS.
* NOTE: Unlike the clipboard, Windows will not synthesize missing text formats for drag and
* drop operations, so we need to check for both CF_UNICODETEXT and CF_TEXT.
*/
fmtetc.cfFormat = CF_UNICODETEXT;
if (p_data_object->QueryGetData(&fmtetc) == S_OK) {
return GHOST_kDragnDropTypeString;
}
fmtetc.cfFormat = CF_TEXT;
if (p_data_object->QueryGetData(&fmtetc) == S_OK) {
return GHOST_kDragnDropTypeString;