1. Tracy Lamb
  2. PowerBuilder
  3. Thursday, 30 June 2022 15:59 PM UTC

Hi all,

I need to be able to re-arrange rows on my dw with dragdrop.  This works fine in my legacy code.  I'm using PB2021 and PFC 12.5 .   

My dw has row select service on, one row at a time.  When I set the dw DragAuto option ON, the row select doesn't work.  I can't click on a new row to change the selection.

I can turn off DragAuto and use the Other event to initiate DragDrop, but when I do that, nothing happens, except row selection works.  In the legacy code, as I dragged a row up or down, it would highlight each row as I was dragging past.  It's not doing anything now.

TIA,

~~~Tracy

 

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Thursday, 30 June 2022 22:47 PM UTC
  2. PowerBuilder
  3. # Permalink

Many thanks to John Fauss,

I created an event ue_mouse_move mapped to pbm_dwnmousemove as suggested. Then put this code in the new event:

// Initiate DragDrop if left-mouse is down...
long ll_row
if KeyDown(KeyLeftButton!) then
   // check that a row is selected...
   ll_row = GetSelectedRow(0)
   if (ll_row < 1) then
      return 0
   end if
   // Start the drag/drop operation
   this.Drag(Begin!)
end if
return 1

~~~Tracy

 

Comment
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Thursday, 30 June 2022 21:03 PM UTC
  2. PowerBuilder
  3. # 1

Not crazy about this solution, but it works... copied from my legacy code

I coded the Other event in the dw as follows:

// Use Drag/Drop to move rows.
long ll_row
if (Message.Number = 512) then
//Check for left button down
if (Mod(Message.WordParm, 2) = 0) then
return
end if

// check that a row is selected...
ll_row = GetSelectedRow(0)
if (ll_row < 1) then
return
end if

// Start the drag/drop operation
this.Drag(Begin!)
end if

Then the Drag/Drop event in the DW is triggered when I release the mouse button... everything works fine from there.  I can re-order the lines in the dw based on the current row and the row passed in to to Drag/Drop event (row that was dropped on).

~~~Tracy

 

 

Comment
  1. John Fauss
  2. Thursday, 30 June 2022 22:11 PM UTC
Unless there is NO alternative, I STRONGLY discourage the use of the "Other" event, as it can be fired literally hundreds or times (or more) in a very short amount of time. Since the event message number 512 is the ID of the Windows "mouse move" event, I want to encourage you instead as an alternative to add a user event to the DW control mapped to the pbm_dwnmousemove event ID. This user event then becomes the MouseMove event for the DW control, and you can stop using the Other event. In this new user event, you can use the Keydown(KeyLeftButton!) PowerScript function in an If statement to determine if the left-mouse button is pressed.
  1. Helpful 1
  1. Tracy Lamb
  2. Thursday, 30 June 2022 22:43 PM UTC
Thank you John,

I created an event ue_mouse_move mapped to pbm_dwnmousemove as suggested. Then put this code in the new event:

// Initiate DragDrop if left-mouse is down...

long ll_row

if KeyDown(KeyLeftButton!) then

// check that a row is selected...

ll_row = GetSelectedRow(0)

if (ll_row < 1) then

return 0

end if

// Start the drag/drop operation

this.Drag(Begin!)

end if

return 1



Works great! I'm very grateful, as I figured the Other event was probably firing for a million reasons and I only needed one... the Message.Number and Message.WordParm were hold-overs from legacy software, I didn't know what they were.

Thanks again,

~~~Tracy

  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 30 June 2022 16:41 PM UTC
  2. PowerBuilder
  3. # 2

Hi Tracy;

   At a basic high level, you would not use the DragAuto property. Instead, you would use the Manual Drag features utilizing the Drag() method and then code the DragWithin, DragEnter, DragLeave & DragDrop events (as required) to capture what row you started with and then what row the App user ended up trying to go to. Then once you know that, the RowsMove() command to make the actual data movement happen.

HTH

Regards ... Chris

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 30 June 2022 20:20 PM UTC
Hi Trcy ... Use the Drag (Begin!) command but first, grab the DWO's Row number that the user is over first. Then issue that command. ;-)
  1. Helpful
  1. Tracy Lamb
  2. Thursday, 30 June 2022 21:05 PM UTC
I know that, but what event do I do that in?

  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 30 June 2022 23:53 PM UTC
MouseMove
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.