Is it possible to create a custom WebDragItem which can include custom properties of the object that is being dragged? If so, can these properties then be received by the receiving control within the DropObject event?
In the DropObject event, we have access to Obj.Sender (but the Sender only has the properties of WebControl class. I want Sender to also expose properties of the actual object that was dropped - a container control, for example, which has custom properties that I want the receiver to use).
Or is there any other way to transfer data between source container to receiving container? Maybe a hidden text field?
The best way I have found for me is to have a dictionary with WeakRefs to each object that are created at the same time as the WebDragItem. Set the RawData to a random key or ControlID and store it in the dictionary with the WeakRef and any other info you want.
I have not tested it but I see there is now WebDragItem.Tag, this appears to be the control that was dropped?
Thanks for your suggestion.
I too wanted to use the WebDragItem.Tag but there seems to be very little documentation about it! No info on how the tag is structured, or what data is to be found in it.
I have found a brilliant work around in this thread… https://forum.xojo.com/53870-web-container-drag-and-drop-with-all-properties/0#p436438
Interesting – I just happened to be messing about with this today. I had a WebImage that was displaying a picture via the URL property. I wanted to drag it to another WebImage control at run time. Although you “see” the picture being dragged from the first control…the second control can’t accept it as a picture. So… I looked at the “Obj” coming into the drop event and found the picture property is Nil. However, the Sender contains a full reference to the original WebImage Control…including the URL property.
I thought it would be easy to simply ask for Obj.Sender.URL — but although Sender says it was WebImage (at run time) – It’s just a WebObject (at design time) --which has no URL property. I thought I’d just create a variable of type WebImageView and set it equal to the Obj.Sender at Run time. That didn’t seem to work either. I finally just said to heck with passing it (doing it right?) – I only have the TWO controls. If one WebImage receives a drop event…it just updates the URL property from the other WebImage. There’s got to be a way to pull stuff out of Obj.Sender – I just haven’t lucked onto it yet.
To find the answer…I had to look within. Introspection allowed me to iterate over and pull out any properties of the Obj.Sender. I knew there had to be an easy enough way.