Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

StartDragging doesn't be trigged

coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

StartDragging doesn't be trigged

Post by coater »

procedure Chromium1StartDragging doesn't be trigged when some words or link were be dragged.
Only Chromium1DragEnter was trigged.

What wrong may I mistake?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: StartDragging doesn't be trigged

Post by salvadordf »

TChromium.OnStartDragging only works in OSR mode.
coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

Re: StartDragging doesn't be trigged

Post by coater »

Thank you!

If I drag a object, Chromium1DragEnter will be triggered two times, how to judge starting and enter?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: StartDragging doesn't be trigged

Post by salvadordf »

I tried to replicate that issue with 2 demos (normal mode and osr mode) and I only saw that event one time.

Are you setting "Result" to false to continue with the default drag handling behavior ?
coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

Re: StartDragging doesn't be trigged

Post by coater »

Oh, :oops:
I don't set Result := true;
Thank you again for your kind help!
coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

Re: StartDragging doesn't be trigged

Post by coater »

Code: Select all

onDragEnter(Sender: TObject;
  const browser: ICefBrowser; const dragData: ICefDragData; mask: Cardinal;
  out Result: Boolean);

begin

  if Dragtime2<Dragtime1 then
     Dragtime2 := Now
    else
    Dragtime1 := Now;  {}
    Result := true;
    if  MilliSecondsBetween(Dragtime1,Dragtime2)>500 then

      begin
       if  dragData.IsLink then
         begin
           aurlstr := dragData.GetLinkUrl;
           SendMessage(Handle, MINIBROWSER_DRAGDATA_MESSAGE, 0, LParam(@aurlstr));
         end else
             begin
               atitle :=  dragData.GetFragmentText;
               if atitle <> ''  then
                   SendMessage(Handle, MINIBROWSER_DRAGDATA_MESSAGE, 1, LParam(@atitle));
             end;
      end;


end;
---------------------------------------
Result := true doesn't act on repeating send.( Chromium1DragEnter will be triggered many times). so I have to add time condition.
Is there a precedure such as onDragrelease? when drag was release the procedure will be triggered.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: StartDragging doesn't be trigged

Post by salvadordf »

If your application uses the OSR mode then you can use a custom TChromiumCore with different versions of these procedures :
  • TChromiumCore.DragTargetDrop(const event: PCefMouseEvent)
  • TChromiumCore.DragTargetDragLeave
coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

Re: StartDragging doesn't be trigged

Post by coater »

If normal mode was used, how to solve this problem? Thank you!
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: StartDragging doesn't be trigged

Post by salvadordf »

The CEF project maintainer suggest using JavaScript to be notified of drag and drop events :
https://magpcss.org/ceforum/viewtopic.php?f=6&t=17115
https://magpcss.org/ceforum/viewtopic.php?f=6&t=13058
https://stackoverflow.com/questions/704564/disable-drag-and-drop-on-html-elements
coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

Re: StartDragging doesn't be trigged

Post by coater »

Ok, Thank you!
Post Reply