[quote=115585:@Michel Bujardet]The method Brock Nash posted is quite interesting. I tried it, and with his help was able to make it work.
Add this method in a module :
Sub draggable(extends wc as webControl, assigns isDraggable as Boolean)
if isDraggable then
To use it:
RectControl1.draggable = true
The drag is absolutely smooth and natural with Rectangle and WebButton I tried. This is perfect. As it stands, it does nothing more than to show how a control can be moved with the mouse. But I am now convinced this is the way to go to implement control drag and drop.[/quote]
Please note that adjusting the DOM like this is completely unsupported.
[quote=115627:@Brock Nash]No Prob. I think adding “s.Append(“e.preventDefault();”)” to the drop event in my example might get it to work in Firefox…
My second example has a slightly better implementation.[/quote]
With Firefox the problem is not the drop, it is the drag. It simply does not occur.
I just tested your version 2. I see you have added the cursor change. It is very convincing.
//stop the browser from opening the file
//Now we need to get the files that were dropped
//The normal method would be to use event.dataTransfer.files
//but as jquery creates its own event object you have to access
//the browser through originalEvent. which looks like this
var files = event.originalEvent.dataTransfer.files;
//Use FormData to send the files
var formData = new FormData();
//append the files to the formData object
//if you are using multiple attribute you would loop through
//but for this example i will skip that
TriggerServerEvent and pass the formdata as an array, or pass files array directly so the websdk can catch it.
We’ve been looking into how to do this and make it work with all of our supported browsers and have come to the conclusion that this is one of those features that just needs to be built into the framework. Otherwise there will be several implementations and none of them will work together.
For what it’s worth, the code laid out above simply makes certain items draggable and certain others into drop targets. If all you care about is that the user dragged from point A to point B then you’re all set. The problem arises when you want to define different data types… for instance if a single container can produce both pictures and text, but you have individual targets for each.
Our goal is to make it replicate the desktop API and behavior as closely as the browsers will allow.
[quote=6636:@Trausti Thor Johannsson]Is it possible to handle drag and drops ? Where a user could drag a file into the browser ?
I just can’t find anything about it, except that it wasn’t possible in earlier versions.
I would be quite OK with a solution where if a user would drag any number of files into the browser, that they would just be added to the file uploader.
Also, is it possible to re-arrange the files inside the file uploader ?[/quote]
[quote=119012:@John Scanlan]Yes my desktop app allows dragging from one table to insert a row to another.
The above seems interesting, but a bit beyond my web app. Of course anything that will speed it up would be worth checking out.[/quote]
The issue with WebListBox is that it does not have the same features as the desktop Listbox. For some reason, the ScrollTo method is there, but no ScrollPosition is available, so you never know where the user has scrolled. Plus there is no RowFromXY to know in which row the object has been dropped. With listboxes that do not scroll it could work, but then WE does not offer any built in support for drag and drop. So you have to go through solutions such as the one I posted. I have seen less elaborate projects, though : http://www.roseindia.net/dojo/dojo-drag-and-drop-examples.shtml http://www.roseindia.net/java/example/java/swing/drag-drop.shtml
A common alternative to the drag and drop metaphor in pure Xojo is to place a right pointing arrow on a button in between the two listboxes. When clicked, it copies or move the left listbox selected row to the right hand side. And another arrow the other way. It is possible because you have the Selected method of knowing which row is selected, even if the WebListBox has scrolled.
[quote=119109:@Greg O’Lone]ScrollPosition kinda relies on uniform height rows, which we do not have on web.
RowFromXY has the same restriction. [/quote]
I understand. But yet you have ScrollTo which sets the first row shown on top of the box. I maybe naive, but does it not mean that you got the number of the topmost shown row available internally in the WebListBox ? Or is it true only when you set it ?
The variable height is duelly noted, when indeed each cell can have EndOfLine in the text of change in style that change its height. But would it not possible to have something like a FixedRowHeight property that would in turn enable having ScrollPosition ?
After a previous discussion about that in a previous thread, I quickly worked on an alternative using TextFields stacked upon each other to form a list, echoing the content of an invisible WebListBox. No smooth scrolling, but ScrollPosition was available. So a workaround is possible. But as John request shows, maybe in error, people tend to view the WebListBox just as the desktop equivalent and hope for the same features.
Yes for Firefox, where apparently no drag occurs. I will need to check what is going on with Internet Explorer. This is a work in progress, though, trying to work client side is not as easy as with Xojo code. We got a proof of concept for Chrome, Mozilla and Safari.
Hopefully we will be able to get this working on all major platforms. It may be possible through HTML5 code.