EnableGadgetDrop() does not work with EditorGadget?

Everything else that doesn't fall into one of the other PB categories.
User avatar
Kiffi
Addict
Addict
Posts: 1526
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

EnableGadgetDrop() does not work with EditorGadget?

Post by Kiffi »

Hello,

why it is not possible to drag files from an explorer-window onto an
EditorGadget?

Code: Select all

If OpenWindow(0, 0, 0, 322, 150, "EditorGadget")
  If CreateGadgetList(WindowID(0))
    EditorGadget(0, 8, 8, 306, 133)
    EnableGadgetDrop(0, #PB_Drop_Files, #PB_Drag_Copy) ; doesn't work
    EnableWindowDrop(0, #PB_Drop_Files, #PB_Drag_Copy) ; Works
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
EndIf
(tested with PB 4.10 Beta 4)

hallodri wrote a workaround for this issue forum using
a callback in the german
but i am more interested in a native PB-Solution.

Greetings ... Kiffi
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Aye, certainly works with a callback okay :

Code: Select all

Global gOldProc 

;Subclasses the list icon gadget.  
Procedure Callback(hWnd,uMsg,wParam,lParam) 
  Protected ReturnValue, numfiles, buffer$ 
  Select uMsg 
    Case #WM_DROPFILES 
      *dropped = wParam 
      numfiles = DragQueryFile_(wParam , -1, 0, 0) 
      For i = 0 To numfiles - 1 
        buffer$=Space(DragQueryFile_(*dropped, i, 0, 0)+1) 
        DragQueryFile_ (*dropped, i, buffer$, Len(buffer$)) 
        AddGadgetItem(1, -1, buffer$) 
      Next 
      DragFinish_(*dropped) 
    Default 
      ReturnValue = CallWindowProc_(gOldProc, hWnd, uMsg, wParam, lParam) 
  EndSelect 
  ProcedureReturn  ReturnValue 
EndProcedure 
  
  
If OpenWindow(0, 0, 0, 300, 300, "Drag 'n' drop",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
  EditorGadget(1, 8, 8, 306, 133) 

 gOldProc = SetWindowLong_(GadgetID(1), #GWL_WNDPROC, @Callback()) 

 DragAcceptFiles_(GadgetID(1), 1) 

  Repeat 
    Select WaitWindowEvent() 
      
      Case #PB_Event_CloseWindow 
      Quit = 1 

    EndSelect 
  Until Quit = 1 
EndIf 
End
Unsure why it shouldn't work with the PB drag/drop library, although if you add

Code: Select all

DragAcceptFiles_(GadgetID(0), 1) 
to your code then the editor gadget at least exhibits the correct cursor when the drag is underway. Haven't tested the actual drop though.
I may look like a mule, but I'm not a complete ass.
freak
PureBasic Team
PureBasic Team
Posts: 5962
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Its probably because the EditorGadget has its own Drag&Drop handling in place on the OS side already.
I will have a look if it can be overwritten.
quidquid Latine dictum sit altum videtur
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I tried using the #EM_SETEVENTMASK message to set/remove all drag/drop notifications (which are not set by default anyhow) but this made no difference.
I may look like a mule, but I'm not a complete ass.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Has anyone done any more with this. I would like to be able to drop private into an editorgadget, but can not find any way to get it to recognize a drop event.

I would like to handle a drag/drop from a listicongadget into an editorgadget and treat the dragged data in a particular manner.

cheers
freak
PureBasic Team
PureBasic Team
Posts: 5962
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

This works since PB 4.30.
quidquid Latine dictum sit altum videtur
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Well, maybe it works for you :D

thanks freak, I'll see if I can get it, now that I know it should work.

cheers

Yep, it sure does. Great :D
Last edited by rsts on Mon Jan 26, 2009 4:44 pm, edited 1 time in total.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

both gadgets in same process structure?

note that the access rights of the reciever have to be same as or higher than those of the origin...
oh... and have a nice day.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Yes, both gadgets are in the same window. I just need to have the editorgadget recognize the drop event so I can obtain the position of the listicongadget from whence it came and act accordingly.

cheers
Post Reply