Troubles with ListBox’ Row “direct copy”

Sometimes, I have to clone a Row (or more) and modify it a little bit later. ’till now, I use cmd-c (ctrl+c) Copy / cmd-v (ctrl+v) Paste. Earlier today, I had the idea to use a different way: use Drag Row + Option Key Down.

The code below Append a copy of the selected Row(s), but also moves the selected Rows to the mouse released position:

[code] If Keyboard.AsyncOptionKey Then
Me.AddRow obj.text
Loop Until Not Obj.NextItem


End If[/code]

As you can notice, I added a Return line before the End If line as a try to disable the “automatic” Drag Rows… but this failed.

I also added (as the first line):

 #Pragma Unused obj

just in case it will disallow the standard Drag (move), but this failed too.

It also add a “parasite” empty row (I do not know from where these “Return” can come).

You may ask me how do I know it is not my code that moves the selected row. The answer is very simple: the demo Rows holds more than one Column (in fact 4 columns), and so, “my code” * create one Column Row(s), moved Rows have the 4 Columns.

  • “my code” is in fact Xojo code, excepted for the If Keyboard.AsyncOptionKey Then …/… End If lines.

Of course, the only case where the original Rows are not moved is when I copy the last Rows… ;-:slight_smile:

The DropObject event doesnt’t have return value. So it is superfluous, unless you have code after the End If.
If you want to disable what you call “automatic” Drag Rows, you have to do this in the DragRow event.

You should read the docs about #pragma Unused. You use it to suppress warnings when you do Analyze Project. The result window of Analyze Project will show all unused variables in each method. You then can delete all unused local variables in your project, but you cannot delete unused method arguments – this where to use #pragma unused.

Yes for both. I noted the Return / #Pragma stuff to show the reader that I make many differents checkings before coming here (I came here once I do not had any idea crazy or not to write xode that will do the trick… ;-:slight_smile:

I just get an eye on the DrawRow event… to… how can I do that there ?

In a current project (different), I added in DragRow:

Return False

move a Row in the ListBox and the Row was moved. I also tried Return True in vain.

I do not understand what to do. Care to explain what you had in mind ?