Possible bug... drag/drop

Everything else that doesn't fall into one of the other PB categories.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Possible bug... drag/drop

Post by srod »

PB 5.21LTS x86, Win 7 pro.

Hi,

having ripped my prog apart wondering why drag/drop was so slow with a ListIcon with lots of rows, have decided that this is a PB problem. Unsure if this is a bug though?

Opinions welcomed before I post a bug report.

Basically, if you drag some text (from any source) and drag over a listicon, then PB's drag/drop lib takes steps to highlight the drag position etc. All well and good (though I wish I could turn this off as it gets in the way).

All good until you drag over a listicon with lots of rows.

Try the following, drag from either listicon (the drag text is actually just some dummy text) and mouse over the left listicon. You'll see that the highlighted row is displayed nicely... no lag.

Now drag over the right listicon. Very slow... at least on my system.

Code: Select all

OpenWindow(0,0,0,480,400,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu) 
TextGadget(10, 20, 20, 200, 40, "Drag over this gadget... no probs!")
ListIconGadget(0,20,60,200,300, "Drag from/to", 195, #PB_ListIcon_FullRowSelect) 
TextGadget(11, 250, 20, 200, 40, "Drag over this gadget... SLOW!")
ListIconGadget(1,250,60,200,300,"Drag from/to", 195, #PB_ListIcon_FullRowSelect) 

For i = 0 To 50
  AddGadgetItem(0, -1, "Row "+Str(i)) 
Next

For i = 0 To 5000
  AddGadgetItem(1, -1, "Row "+Str(i)) 
Next

EnableGadgetDrop(0, #PB_Drop_Text, #PB_Drag_Copy) 
EnableGadgetDrop(1, #PB_Drop_Text, #PB_Drag_Copy) 

Repeat 
  eventID = WaitWindowEvent() 
  Select eventID 
    Case #PB_Event_GadgetDrop 
      If EventGadget() =1
        AddGadgetItem(EventGadget(), GetGadgetState(EventGadget()), EventDropText()) 
      EndIf
    Case #PB_Event_Gadget 
      If EventType() = #PB_EventType_DragStart
        DragText("TEST!") 
      EndIf 
 EndSelect 
Until eventID = #PB_Event_CloseWindow 
Is this a bug? I know 5000 rows in a listicon is a bit extreme, but, well, not hugely untoward. My own gut feeling is this is a bug and that PB's drag/drop lib is not being very efficient in the way it monitors the row beneath the cursor etc.

It is playing merry buggery with my program.

Thanks.
I may look like a mule, but I'm not a complete ass.
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Re: Possible bug... drag/drop

Post by USCode »

I'm with you, it seems like a bug. It should only have to loop through the visible items in the list and not the entire list as it doesn't scroll when in drag mode.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Possible bug... drag/drop

Post by srod »

Yes, think I'll post it in the bug section. Thanks.

Am having to code my own OLE drag/drop routines to get around this. Oh well. Can't sit around for a fix. :)
I may look like a mule, but I'm not a complete ass.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Re: Possible bug... drag/drop

Post by Sparkie »

LVN_ITEMCHANGING appears to be the culprit.

Code: Select all

Procedure WinCallback(hwnd, msg, wParam, lParam)
  Static hiRow
 result = #PB_ProcessPureBasicEvents 
 Select msg 
   Case #WM_NOTIFY 
     *pnmhdr.NMHDR = lParam
     Select *pnmhdr\code
       Case #LVN_ITEMCHANGING
         *pnmlv.NMLISTVIEW = lparam
         
         If *pnmlv\iItem >= hiRow
           hiRow = *pnmlv\iItem
         EndIf
         
         SetGadgetText(20, "Last Row sending #LVN_ITEMCHANGING was " + hiRow)
     EndSelect
     
      EndSelect 
  ProcedureReturn result 
EndProcedure 
OpenWindow(0,0,0,480,600,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu) 
TextGadget(10, 20, 20, 200, 40, "Drag over this gadget... no probs!")
ListIconGadget(0,20,60,200,300, "Drag from/to", 195, #PB_ListIcon_FullRowSelect) 
TextGadget(11, 250, 20, 200, 40, "Drag over this gadget... SLOW!")
ListIconGadget(1,250,60,200,300,"Drag from/to", 195, #PB_ListIcon_FullRowSelect) 
TextGadget(20, 5, 370, 475, 250, "")
SetWindowCallback(@WinCallback())
For i = 0 To 50
  AddGadgetItem(0, -1, "Row "+Str(i)) 
Next

For i = 0 To 500
  AddGadgetItem(1, -1, "Row "+Str(i)) 
Next

EnableGadgetDrop(0, #PB_Drop_Text, #PB_Drag_Copy) 
EnableGadgetDrop(1, #PB_Drop_Text, #PB_Drag_Copy) 

Repeat 
  eventID = WaitWindowEvent() 

  Select eventID 
    Case #PB_Event_GadgetDrop 
      If EventGadget() =1
        AddGadgetItem(EventGadget(), GetGadgetState(EventGadget()), EventDropText()) 
      EndIf
    Case #PB_Event_Gadget 
      If EventType() = #PB_EventType_DragStart
        DragText("TEST!") 
      EndIf 
 EndSelect 
Until eventID = #PB_Event_CloseWindow 
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Possible bug... drag/drop

Post by srod »

Nice one Sparkie.

Quite why those notifications should be sent is a bit of a puzzle in what would be a modal loop governed by OLE? A symptom of the bug no doubt, though should help Fred/Freak track the cause down. :)

I am about half way through implementing drops directly through OLE and am seeing no such 'weirdness' thus far.
I may look like a mule, but I'm not a complete ass.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Re: Possible bug... drag/drop

Post by Sparkie »

srod wrote:I am about half way through implementing drops directly through OLE and am seeing no such 'weirdness' thus far.
Better you than me. :P
Good luck my friend!
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply