Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Drag & drop from host app to extension

New Here ,
Sep 03, 2018 Sep 03, 2018

I've seen there are demos about how to D&D from within the extension and from extension to host app, but not about how to do it from the host app. Is it possible to do? I'm using ondragover, ondragend and ondrop on the body and it only fires ondragover when I'm dragging something from the host. It is not even working with onmouseup.

Using CEP8 with Illustrator.

677
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Sep 05, 2018 Sep 05, 2018

Did you prevent default event management on dragover ?

$("html").on("dragover", function(event) {

        event.preventDefault(); 

        event.stopPropagation();

    });

    $("html").on("dragleave", function(event) {

        event.preventDefault(); 

        event.stopPropagation();

    });

    $("html").on("drop", function(event) {

        event.preventDefault(); 

        event.stopPropagation();

        //The jsx script to be run…

    });

Otherwise the event is managed by the html engine thus ignoring

...
Translate
People's Champ ,
Sep 03, 2018 Sep 03, 2018

When the drop event is fired, it generally means you have selected something inside the UI. Once that said, it should be all about getting html compliant data from the current selection. It may be SVG export or whatever that once exported is loaded inside the panel.

1. catch drop event

2. export current selection to HTML compliant format

3. Load data into HTML

One hiccup though, while exportFile is synchronous, file system operation may differ thus leading to out of date or missing ressources.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 05, 2018 Sep 05, 2018

Thank you for your answer.

That's not what's happening. The problem is that the drop event is not being fired when I select something in Illustrator and drop it in my extension.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 05, 2018 Sep 05, 2018

Did you prevent default event management on dragover ?

$("html").on("dragover", function(event) {

        event.preventDefault(); 

        event.stopPropagation();

    });

    $("html").on("dragleave", function(event) {

        event.preventDefault(); 

        event.stopPropagation();

    });

    $("html").on("drop", function(event) {

        event.preventDefault(); 

        event.stopPropagation();

        //The jsx script to be run…

    });

Otherwise the event is managed by the html engine thus ignoring your jsx call.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 05, 2018 Sep 05, 2018

Thank you! That did the trick!

Is there any documentation where I could have seen this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 05, 2018 Sep 05, 2018
LATEST

Well there are the SDK documentation (probably some D&D démos). But as CEP rely on HTML, most html "tricks" can find answers while googling them. There will be only little area where answers can only be found in the sdk docs.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines