At the startDrag event you can place any data (like a record object) in the data property of the JSEvent.
At the onDrop event you can read this out and use it for further processing.
So you have full control over what data you need.
you can do this for the source, but not for the target as the selected index is not changed.
I am drag and dropping in the same table, my goal is to change the records order, by picking up the order field in event.data (done) and then change it for the dropped one - 1. but I can’t find the way to extract the dropped element value from event.getSource(). while this displays ok with application.ouput:
TEXT_FIELD[name:event_id,x:-35,y:-19,width:0,height:0,value:5]
I do not know how to handle it to get the value, 5 in this example.
fixed that with the utils.StringMiddle which could strip the string while .substr couldn’t.
In another test, I now have been able to re-order records with onDrop using a specific order field, and dropping on it.( until this event can return the record index in a future design?)
I cheat a little bit by using Ctrl to decide if I should insert the current dragged record above or below the dropped one. It displays a + sign, so this is a bit misleading. Obvious drawback, multiselection cannot be used.
This is a Subversion repository. You can check out the solution via the Subclipse plugin for instance.
But I agree with you. It would be nice as well to have these releases available as .servoy file as well.
thanks. I don’t use subversion, I guess I should but have done nothing serious with servoy yet, so I don’t keep old versions.
And I had made this solution running already. But good point you cleaned it, it opens lots of ideas for smart UIs.
I also did a dirty one to sort records by drag and drop in a portal using a order number record (necessary untill drop returns the rec index maybe in a future version). I have been using “normal drop” to insert above, and ctrl+drop to insert below. maybe another key modifier for dnd would be better? shift is taken, not much left… how about detecting dnd with the right mouse button? if anyone has a better idea…
Would be nice to be able to highlight valid drop zones in the onDrag() event (so the user knows where to drag to). But we need an onDragCancelled() event to reliably turn off the highlighter in case the user doesn’t drop the event on a place where it is handled.
2- Clear product list selections after drop is finished
Tnx for pointing out the reason why we chose to provide the example solutions through SVN and not as downloads: There are currently 3 different versions of the solution attached to this thread, making it easy to pick the wrong one. Secondly, if you already had downloaded and installed an earlier version and mode some modifications yourself and someone posts a new version, you have to start doing manual compares etc. etc.
Therefor: we provide the examples in SVN: people can check them out, provide patches, look at the history etc. Way better imho.
As for your enhancements/changes:
1: Nice addition
2: I don’t see this working, besides the point if this is actually an improvement.
Best to supply a patch, instead of a new .servoy file, so people can actually see the changes made and merge them into the project they might already have and we could merge it back into the example solution available in the SVN.
Tnx for pointing out the reason why we chose to provide the example solutions through SVN and not as downloads: There are currently 3 different versions of the solution attached to this thread, making it easy to pick the wrong one. Secondly, if you already had downloaded and installed an earlier version and mode some modifications yourself and someone posts a new version, you have to start doing manual compares etc. etc.
Therefor: we provide the examples in SVN: people can check them out, provide patches, look at the history etc. Way better imho.
I like the new example SVN. Supply guidelines for contributing and we’ll follow them. Even put up stuff of our own. Without guidelines, I didn’t want to assume that it was there for us to modify stuff.
pbakker:
2: I don’t see this working, besides the point if this is actually an improvement.
It’s a little thing and not constrained to D&D. Nice to know the tip if you’re trying to clear the multiple selections of a list. Which I prefer over leaving the source list selected after the drop is finished.
pbakker:
Best to supply a patch, instead of a new .servoy file, so people can actually see the changes made and merge them into the project they might already have and we could merge it back into the example solution available in the SVN.
If you could give instructions on how to do a patch along with the guidelines that would be great. We’re still not 100% comfortable with SVN even though it’s in full use here.
david:
If you could give instructions on how to do a patch along with the guidelines that would be great. We’re still not 100% comfortable with SVN even though it’s in full use here.
if you checked out the project from servoy’s svn
made the changes in that project.
Then make sure that you have the last updates (team->update)
then create a patch:
Team->create patch
Enter a file name in the Save to the file system option
Also in this wizard screen you can even select the changes you want to create a patch for,
In the next wizard screen select the patch root. Workspace root is almost always good.
Then when you press finish you have created a patch file that we can apply.
Maybe add onDrag(), onDragOver(), onDrop() at the record level in addition to (or maybe instead of) the form level.
that would be the ultimate goal indeed, but just giving us back the row-id (or recordObject) of the drop on the table-view, would cover 95% of our needs…
Maybe add onDrag(), onDragOver(), onDrop() at the record level in addition to (or maybe instead of) the form level.
that would be the ultimate goal indeed, but just giving us back the row-id (or recordObject) of the drop on the table-view, would cover 95% of our needs…
Showing the user what record they’re dropping on is core to DnD. The Servoy marquee box just shows that you’re dragging something. Until it gets to this point, I’m not convinced it’s all that great.
Showing the user what record they’re dropping on is core to DnD
I second that, David, and thanks for posting your tweaks!
Actually, when we drop something on a form, we would also need some way to know if it was a DRAGNDROP.COPY or a DRAGNDROP.MOVE, because we may want a different behaviour for each event.
If you just support a move then return MOVE if you just want to support copy (CTRL is pressed) then return COPY
But if you just always wants to drag then just return DRAGNDROP.MOVE|DRAGNDROP.COPY and this is what you most want i think.
However, my understanding was that, if the method returns only DRAGNDROP.MOVE or only DRAGNDROP.COPY, then no modifier keys are needed, and there is no way to differentiate the two…