Blender-DDS-Addon icon indicating copy to clipboard operation
Blender-DDS-Addon copied to clipboard

Add Drag and Drop Import

Open matyalatte opened this issue 9 months ago • 0 comments

Blender 4.1 got APIs for drag-drop events. https://docs.blender.org/api/current/bpy.types.FileHandler.html

You can't overwrite the drag-drop events on the image editor. But you can add a new event to the DDS panel.

def is_dds_panel(context):
    return (context.area and context.area.type == 'IMAGE_EDITOR'
            and context.region and context.region.type == 'UI'
            and context.region.active_panel_category == 'DDS')

class DDS_FH_import(bpy.types.FileHandler):
    bl_idname = "DDS_FH_import"
    bl_label = "File handler for dds import"
    bl_import_operator = "dds.import_dds"
    bl_file_extensions = ".dds"

    @classmethod
    def poll_drop(cls, context):
        return is_dds_panel(context)

It means, you can drop dds files on the addon's panel to import them. dnd

matyalatte avatar May 12 '24 00:05 matyalatte