It is currently Sat Dec 14, 2019 6:05 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Mon Nov 22, 2010 3:20 pm 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1981
Location: Germany
It took me a while to figure this out and in my eyes it's a pretty strange bug. The following code explains best I guess:
Code:
Enumeration
   #Window
   #Frame
   #Container
   #ContainerString
   #Button
EndEnumeration


If OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 400, 90, "Drag'n'Drop Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

   Frame3DGadget(#Frame, 0, 0, 400, 90, "")  ; 1) Comment this and drag'n'drop works, frame isn't visible

   ContainerGadget(#Container, 0, 0, 400, 60)
      StringGadget(#ContainerString, 10, 10, 380, 40, "Drag a file (or folder) to display its path")
       EnableGadgetDrop(#ContainerString, #PB_Drop_Files, #PB_Drag_Move)
   CloseGadgetList()

   ButtonGadget(#Button, 10, 60, 380, 20, "Button")
   ; EnableGadgetDrop(#Button, #PB_Drop_Files, #PB_Drag_Move)  ; 2) Uncomment this while "1)" is still uncommented, frame gets visible + position is shifted a little & drag'n'drop works now


   Repeat
      Select WaitWindowEvent()
         Case #PB_Event_GadgetDrop
            SetGadgetText(EventGadget(), EventDropFiles())
         Case #PB_Event_CloseWindow
            Break
      EndSelect
   ForEver
EndIf


If someone has a good understandable workaround for this, please let me know.

_________________
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Mon Nov 22, 2010 3:53 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5890
Location: Wales, UK
It's because the 3DFrameGadget is in the GadgetList. Define it outside of the list, just as the button is, then drag n drop of the StringGadget works fine.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Mon Nov 22, 2010 4:48 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Mar 02, 2004 1:20 pm
Posts: 1034
Location: Amphibios 9
this one works for me:
Code:
[...]
ContainerGadget(#Container, 0, 0, 400, 60)
EnableGadgetDrop(#Container, #PB_Drop_Files, #PB_Drag_Move)
[...]


Greetings ... Kiffi

_________________
Can't decide if i need a hug, an XXL coffee, 6 shots of vodka or 2 weeks of sleep.


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Mon Nov 22, 2010 5:10 pm 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1981
Location: Germany
IdeasVacuum wrote:
It's because the 3DFrameGadget is in the GadgetList. Define it outside of the list, just as the button is, then drag n drop of the StringGadget works fine.
Sorry, I don't understand you. OpenWindow() creates the standard gadget list where I put my frame, button and container. The string is in the container gadget list and doesn't get drag'n'drop events when I define the frame before the container. This doesn't make any sense to me.

Why does drag'n'drop magically work when I:
  • Remove the Frame3DGadget()
  • Enable drag'n'drop for the button


I edited the code a little:
Code:
Enumeration
   #Window
   #Frame
   #Container
   #ContainerString
   #Button
EndEnumeration


If OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 400, 90, "Drag'n'Drop Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

   Frame3DGadget(#Frame, 0, 0, 400, 90, "", #PB_Frame3D_Flat)  ; 1) Comment this and drag'n'drop works, frame isn't visible

   ContainerGadget(#Container, 10, 10, 380, 40)
      StringGadget(#ContainerString, 0, 0, 380, 40, "Drag a file (or folder) to display its path")
       EnableGadgetDrop(#ContainerString, #PB_Drop_Files, #PB_Drag_Move)
   CloseGadgetList()

   ButtonGadget(#Button, 10, 60, 380, 20, "Button")
   ; EnableGadgetDrop(#Button, #PB_Drop_Files, #PB_Drag_Move)  ; 2) Uncomment this while "1)" is still uncommented, drag'n'drop works now


   Repeat
      Select WaitWindowEvent()
         Case #PB_Event_GadgetDrop
            SetGadgetText(EventGadget(), EventDropFiles())
         Case #PB_Event_CloseWindow
            Break
      EndSelect
   ForEver
EndIf

_________________
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Mon Nov 22, 2010 7:44 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5890
Location: Wales, UK
All the gadgets in the list before CloseGadgetList() are in that list. So, list the Frame3DGadget after CloseGadgetList(). That's it :wink:

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Mon Nov 22, 2010 8:51 pm 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1981
Location: Germany
@IdeasVacuum
Well, thanks. That might be a workaround but it doesn't explain what it all has to do with this Frame3DGadget(). See, every other gadget seems to work, just the frame makes trouble.
Also I don't get why all gadgets before closelist should be in the container list. I mean OpenWindow() creates a list and the container a sub list that is closed with that function.

@Kiffi
Do you get the same effects as I do with my sample code?

_________________
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Mon Nov 22, 2010 10:00 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5890
Location: Wales, UK
OpenWindow does not create a gadget list per say, it's the CloseGadgetList() function which declares "all gadgets listed above are members of this list", thus defining them as a related group.

Frame3DGadget() "is decorative only" but it's the first gadget in the list found by drag n drop because it is the outer perimeter of those gadgets. So to me, it's perfectly logical that the Frame3DGadget() does not belong in that specific list. It is fair to say that, given it's only decorative, one would not expect it to get in the way of anything but the gadgets seem have a Z order - if that is true, it's more likely to be an API thing than a PB thing no?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Mon Nov 22, 2010 10:38 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8006
Location: Fort Nelson, BC, Canada
This presents as a bug. The Frame3D gadget is documented as not receiving any events, yet this is apparently not the case. I cut a region out of the frame3d gadget and this allowed the dragdrop to work, which led me to believe that its event-processing is conflicting with the gadgets inside it. So then I left its clipping region untouched and disabled it. This also allowed the dragdrop to work. A fix is needed on the Frame3D imho. One possible approach could be that PB automatically removes the region inside the lines on creation, this way it truly would be "decorative only" as it doesn't exist beyond it's drawn lines.

Code:
Enumeration
   #Window
   #Frame
   #Container
   #ContainerString
   #Button
EndEnumeration


If OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 420, 110, "Drag'n'Drop Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   StickyWindow(#window, 1)
   Frame3DGadget(#Frame, 10, 10, 400, 90, "")

   DisableGadget(#frame, 1) ;<-------- Allows the dragdrop to work; Shouldn't be necessary
   
   ContainerGadget(#Container, 20, 20, 380, 60)
      StringGadget(#ContainerString, 10, 10, 360, 40, "Drag a file (or folder) to display its path")
       EnableGadgetDrop(#ContainerString, #PB_Drop_Files, #PB_Drag_Move)
   CloseGadgetList()

   ButtonGadget(#Button, 20, 70, 360, 20, "Button")

   Repeat
      Select WaitWindowEvent()
         Case #PB_Event_GadgetDrop
            SetGadgetText(EventGadget(), EventDropFiles())
         Case #PB_Event_CloseWindow
            Break
      EndSelect
   ForEver
EndIf

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Mon Nov 22, 2010 11:11 pm 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1981
Location: Germany
@IdeasVacuum
Not a long time ago we had to use CreateGadgetList() along with OpenWindow() and now the gadget list is automatically created. The #PB_Window_NoGadgets flag was added to prevent this behavior.

@netmaestro
Thanks. That's a fix I can live with for now.

By the way, do you understand why adding EnableGadgetDrop() for the following button also works?

_________________
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Tue Nov 23, 2010 11:25 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5890
Location: Wales, UK
Yeah, it is a bug then. A work-around would be to draw your own lines.

EnableGadgetDrop() for the following button didn't exactly work on my machine, I could only drag and drop to the button itself.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Mon Jul 29, 2013 4:30 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13662
Location: France
Fixed. Now the framegadget() is disabled by default to avoid any events.


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Wed Aug 07, 2013 3:07 pm 
Offline
Addict
Addict

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 1056
Location: Russia
Fred wrote:
Fixed. Now the framegadget() is disabled by default to avoid any events.
I am against this fix!
Now FrameGadget() looks ugly!
Image
You have to insert a string.
Code:
DisableGadget(0, 0)

_________________
Library XP_Menu_Lib - office menu; HID_Lib - USB Library
Torrent client - pbTorrent (source code); Create driver in PureBasic.


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Wed Aug 07, 2013 3:29 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Mar 24, 2004 11:04 pm
Posts: 902
Location: Seattle, USA
User_Russian wrote:
Fred wrote:
Fixed. Now the framegadget() is disabled by default to avoid any events.
I am against this fix!
Now FrameGadget() looks ugly!
Image
You have to insert a string.
Code:
DisableGadget(0, 0)

Not sure I undestand this fix either, why would we want any gadget to appear disabled by default?
There must be another solution to this issue?


Top
 Profile  
Reply with quote  
 Post subject: Re: [Done] Drag'n'Drop on Container inside Frame doesn't wor
PostPosted: Wed Aug 07, 2013 4:57 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13662
Location: France
I had tested only with skin on, so i didn't notice this. Back to the drawing board !


Top
 Profile  
Reply with quote  
 Post subject: Re: Drag'n'Drop on Container inside Frame doesn't work
PostPosted: Wed Aug 07, 2013 7:07 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Mar 09, 2006 9:24 am
Posts: 263
Location: S. Kor
It seems to be due to the Z-order.
Here is a workaround.
All the gadgets except the panel and frame gadgets need the SetWindowPos_() line, or at least the parent gadget(if any).

Code:
If OpenWindow(0, 0, 0, 620, 550, "FrameGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
  FrameGadget(0, 10,  5, 600, 500, "FrameGadget Standard")
  DisableGadget(0, 0)
 
  FrameGadget(1, 20,  20, 550, 450, "", #PB_Frame_Single)
  DisableGadget(1, 0)
 
  FrameGadget(2, 30, 30, 500, 400, "", #PB_Frame_Double)
  DisableGadget(2, 0)
 
  h = ContainerGadget(4, 45, 45, 400, 60, #PB_Container_Single)
    SetWindowPos_(h, #HWND_TOP, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE) ;it must be added.
   
    h = StringGadget(5, 10, 10, 380, 40, "Drag a file (or folder) to display its path")
    ;SetWindowPos_(h, #HWND_TOP, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE)
   
    EnableGadgetDrop(5, #PB_Drop_Files, #PB_Drag_Move)
  CloseGadgetList()
 
 
  h = ButtonGadget(6, 45, 150, 380, 20, "Button 6")
  SetWindowPos_(h, #HWND_TOP, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE) ;it must be added.
  EnableGadgetDrop(6, #PB_Drop_Files, #PB_Drag_Move)
 
 
  h = SpinGadget(7, 45, 180, 380, 30, 0, 100)
  hUpDown = GetWindow_(h, #GW_HWNDNEXT)
  Debug hUpDown
  SetWindowPos_(hUpDown, #HWND_TOP, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE)
  SetWindowPos_(h, #HWND_TOP, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE) ;it must be added.
  EnableGadgetDrop(7, #PB_Drop_Files, #PB_Drag_Move)
  Debug GetWindow_(h, #GW_HWNDNEXT)
 
  h = ScrollAreaGadget(8, 45, 220, 380, 50, 500, 100)
    SetWindowPos_(h, #HWND_TOP, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE) ;it must be added.
    h = ButtonGadget(13, 10, 15, 80, 24, "Button 13")
  CloseGadgetList()
  EnableGadgetDrop(13, #PB_Drop_Files, #PB_Drag_Move)
 
 
  PanelGadget(9, 45, 280, 300, 100)    ; it seems to have no need to add the SetWindowPos_() line.
    AddGadgetItem(9, -1, "Panel 1")
    h = ButtonGadget(10, 10, 15, 80, 24,"Button 10")
   
    h = ButtonGadget(11, 95, 15, 80, 24,"Button 11")
   
    AddGadgetItem(9, -1, "Panel 2")
    h = ButtonGadget(12, 10, 15, 80, 24,"Button 12")
   
  CloseGadgetList()
  EnableGadgetDrop(10, #PB_Drop_Files, #PB_Drag_Move)
  EnableGadgetDrop(11, #PB_Drop_Files, #PB_Drag_Move)
  EnableGadgetDrop(12, #PB_Drop_Files, #PB_Drag_Move)
 
 
  h = FrameGadget(3, 40, 40, 450, 350, "", #PB_Frame_Flat)
  DisableGadget(3, 0)
 
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_GadgetDrop
        Debug Str(EventGadget()) + " " + EventDropFiles()
      Case #PB_Event_CloseWindow
        Break
    EndSelect
  ForEver
EndIf


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye