Robert,
answer is no. I don’t even know what it does. I am still looking for the doc, and even a working example, and I am not the only one obviously, viewtopic.php?f=22&t=13507
the weird thing is that it works in web mode, but this maybe a lucky side effect.
there maybe an explanation in the wiki, but no way to access that for me (account created and confirmed but never worked…) and no way to re-create one.
Rob,
I could, I am sure you’ll locate the error instantly if you confirm that it works, but I’d rather understand the beast myself.
lesouef:
Robert,
answer is no. I don’t even know what it does.
Then there is your issue.
The onDrag needs to allow the drag to happen. You accomplish this by returning either one of those constants.
When you return nothing or return DRAGNDROP.NONE then the drag won’t happen and therefor the onDragOver will never trigger.
In the onDragOver you have to allow the Drop by returning true or false, true means you will allow the drop and onDrop will trigger.
So it’s sort of a cascading approach. If you disallow it somewhere in the chain the rest will simply not trigger.
lesouef:
the weird thing is that it works in web mode, but this maybe a lucky side effect.
I think so too.
lesouef:
there maybe an explanation in the wiki, but no way to access that for me (account created and confirmed but never worked…) and no way to re-create one.
Just send an email to Servoy, they will fix/reset it for you.
DRAGNDROP is true after startDrag, selectex indexes are correct (output to console).
then I drag over the destination table, the dragOver is not triggered… what can block this event?
A bit better using DRAGNDROP.MOVE (what the hell is the difference, copy returns 1, move returns 2…)
I now get the “forbidden drag” sign instead of nothing and the onDragOver is triggered, but that’s all, no way to drop. I am obviously missing a step…
Just checked the wiki (I was mislead by some wrong links you can find in some places…), there is no real explanation, 3 times the same startDrag example…
Probably why I already gave up on Servoy 2 years ago… How did you find your way?
// attached to source table
function startDrag(event)
{ var data = ;
var selection = foundset.getSelectedIndexes();
for(i in selection)
{ application.output(“id selected=”+selection*); // to check*
_ data.push(foundset.getRecord(selection*));_
_ }_
_ event.data = data ;_
_ return DRAGNDROP.MOVE;_
_}_
_//attached to dest table*_ function onDragOver(event) { var source = event.getSource(); * if(source && event.data)* * { return DRAGNDROP.COPY;* * }* } function onDrop(event) { application.output(“drop seen”); * var $order_id = forms.main.orderid ;
_ // Check the event object for multiple product records*_ * for(i in event.data)* { var record = event.data*; //application.output(“search_r=”+record.productname); _ if (foundset.getSize()>0) // Check if product already in order*
* { var fs = foundset.duplicateFoundSet(); if(fs.find()) { fs.productid = record.productid; if(fs.search()) // product exists in order, increment qty*
* { fs.getRecord(fs.getSelectedIndex()).quantity += 1; } else if(foundset.newRecord()) // product did NOT exist, add a new record* * { orderid = $order_id ;*
* unitprice = 99 ; productid = record.productid; unitprice = record.unitprice; quantity = 1; discount = 0.0; } } } else //add new record not really smart but did nto spend time to clean this*
* { foundset.newRecord();_ orderid = $order_id ; _ unitprice = 99 ; productid = record.productid; unitprice = record.unitprice; quantity = 1; discount = 0.0; } } }* thx for help, but I am a bit fed up to bother you (other dev people) for the lack of proper ref for this new feature…_
Doing a quick scan over your code I believe the problem lies in this method:
function onDragOver(event) {
var source = event.getSource();
if(source && event.data) {
return DRAGNDROP.COPY;
}
}
You should use return true if you want to accept a drop on this element. False if you don’t.
Also I believe the getSource will give the source object from the draggedover object. Not from the dragged object.
Anyway, the following code should work.
function onDragOver(event) {
var source = event.getSource();
if(source && event.data) {
return true;
} else {
return false;
}
}
lesouef:
thx for help, but I am a bit fed up to bother you (other dev people) for the lack of proper ref for this new feature…
I understand Paul Bakker is working hard on this (on the wiki). It seems they like to put it out when it’s all done, instead of releasing smaller parts of it.
I’ll give it a try, though I don’t understand all of it, I feel I missed lesson 1 one this.
and about the wiki, (check the servoy-stuff blog) I could say a lot, but I’ll sum up here:
why the hell is the feature out before the doc? where was the hurry?
Paul, if you read this, I have nothing against your work at all, but there should be a fixed way of doing things, and a new feature should not be out before the tools which go along with it. You only see new users, but do not evaluate the ones you loose, fed up after 2 weeks of attempts; the 1st step on is a key one: new users will come for new features first, for features they miss in their existing apps, not because you display a table, right? so the best documented features should be the new ones. The way you do now is OK for the “kernel” of servoy, but does not work for outsiders.
Work fines, thanks you very much Robert.
Now trying to understand… and I cannot figure out why I need this onDragOver to return true, return to what? which code reads this?
I hate magic solutions…
and what is the DRAGNDROP.COPY for?
Servoy reads it. Just like you can return true/false in the onDataChange event to allow/prevent a datachange…or the onHide event…same thing. Return true/false to allow/prevent a close of a Form In Dialog (or moving away from a form). etc.
Now the DRAGNDROP.COPY vs MOVE…I believe the COPY is when you drag with the option-key pressed…kinda like you do in the windows explorer/finder.
I haven’t played with this though but I saw Johan demo this at ServoyCamp.
Now the DRAGNDROP.COPY vs MOVE…I believe the COPY is when you drag with the option-key pressed…kinda like you do in the windows explorer/finder.
I haven’t played with this though but I saw Johan demo this at ServoyCamp.
Robert is right: On any platform there are drag ‘n’ drop modes: Move and Copy. Move is the default behavior for dnd, copy can be achieved by using the correct modifier (“Control” on Windows).
In 5.0 final there was a bug in this area, which was corrected in 5.0.1, but Sean’s demo, created prior to 5.0.0 final didn’t take this into account, hence why it didn’t work.
Also look at the doc that is generated when you let servoy generated the ondrag method for you:
Handle start of a drag, it can set the data that should be transfered and should return a constant which dragndrop mode/modes is/are supported.
Should return a DRAGNDROP constant or a combination of 2 constants:
DRAGNDROP.MOVE if only a move can happen,
DRAGNDROP.COPY if only a copy can happen,
DRAGNDROP.MOVE|DRAGNDROP.COPY if a move or copy can happen,
DRAGNDROP.NONE if nothing is supported (drag should start).
There it is explained.
you should return one or a combination of those.
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.
I got that ok now.
I guess I should submit an improvement as the index is not returned on drop, so modifying a specific record in the target table can’t be done.
but this has been discussed already I think.
another interesting feature would be display/emphasize the record line in betwen 2 records, to be able to re-order records via dnd, assuming one can drag and drop in the same table and the index returned would the one right under the line.
lesouef:
I got that ok now.
I guess I should submit an improvement as the index is not returned on drop, so modifying a specific record in the target table can’t be done.
but this has been discussed already I think.
another interesting feature would be display/emphasize the record line in betwen 2 records, to be able to re-order records via dnd, assuming one can drag and drop in the same table and the index returned would the one right under the line.
Drop invitations and showing valid target destinations are fundamental aspects of the DnD design pattern. Without them, it’s not really…DnD. It’s moving data from one place to another.
and by the way, my usual ignorance has not found how to extract the value of the ondrop event source.
it does not seem to be an array or object or string, all I can do is output it. what am I missing to get the value if the dropped field?