This question is locked. New answers and comments are not allowed.

Scott Waye
Top achievements
Rank 2
Iron
Iron
Veteran
Scott Waye
asked on 07 Jul 2013, 12:51 PM
Using Safari 6.0.5 on Mac OS 10.8.4, I want to drop files from outside Safari on to nodes in the tree view. I have this working fine on Windows. I see from around the internet:
http://social.msdn.microsoft.com/Forums/silverlight/en-US/faf922b4-370c-4901-9e87-385ef410e61f/silverlight-5-drag-and-drop-on-mac-os-x-1075-and-safari
http://connect.microsoft.com/VisualStudio/feedback/details/726450/silverlight-5-drag-from-file-system-does-not-work-on-mac-osx-10-7-running-safari
that this may be broken in the latest versions of Safari, so before I spend a lot of time looking for workarounds using HTML 5 events and FileReader() have you already investigated this and got a working example for Macs?
I've read http://msdn.microsoft.com/en-us/library/ee670998%28VS.95%29.aspx also but as mentioned elsewhere this works for the events except the drop event which is not propagated to Silverlight.
Thanks,
Scott
http://social.msdn.microsoft.com/Forums/silverlight/en-US/faf922b4-370c-4901-9e87-385ef410e61f/silverlight-5-drag-and-drop-on-mac-os-x-1075-and-safari
http://connect.microsoft.com/VisualStudio/feedback/details/726450/silverlight-5-drag-from-file-system-does-not-work-on-mac-osx-10-7-running-safari
that this may be broken in the latest versions of Safari, so before I spend a lot of time looking for workarounds using HTML 5 events and FileReader() have you already investigated this and got a working example for Macs?
I've read http://msdn.microsoft.com/en-us/library/ee670998%28VS.95%29.aspx also but as mentioned elsewhere this works for the events except the drop event which is not propagated to Silverlight.
Thanks,
Scott
6 Answers, 1 is accepted
0
Hi Scott,
I've been trying to workaround the issue but it definitely seems that the Silverlight plug-in doesn't receive any proper notification of the drop action in Safari on Mac and unfortunately I was also not able to come up with any solutions.
This is why the RadTreeView control also can't detect the drop operation or handle it in any way. I'm afraid that at the moment we can't suggest nor implement any solutions for the same.
Regards,
Tina Stancheva
Telerik
I've been trying to workaround the issue but it definitely seems that the Silverlight plug-in doesn't receive any proper notification of the drop action in Safari on Mac and unfortunately I was also not able to come up with any solutions.
This is why the RadTreeView control also can't detect the drop operation or handle it in any way. I'm afraid that at the moment we can't suggest nor implement any solutions for the same.
Regards,
Tina Stancheva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Scott Waye
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 14 Jul 2013, 01:50 PM
Ok thanks,
I managed to work around it with a some Html 5 events and a Scriptable event in the Silverlight code.
I managed to work around it with a some Html 5 events and a Scriptable event in the Silverlight code.
0

Cavit
Top achievements
Rank 1
answered on 23 Apr 2015, 01:57 PM
Do you know if there is a fix for drag and drop issue for Silverlight on Safari - Mac ?
Thanks
0
Hi Cavit,
Currently we have no sample with implemented workaround. I guess Scott has used the techniques described here.
Regards,
Petar Mladenov
Telerik
Currently we have no sample with implemented workaround. I guess Scott has used the techniques described here.
Regards,
Petar Mladenov
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0

Scott Waye
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 27 Apr 2015, 03:43 PM
Yes, the javascript looks like:
function handleDropEvent(oEvent) {
// Prevent default operations in DOM
oEvent.preventDefault();
var agControl = document.getElementById("AgControl1");
var flag = agControl.dragDrop(oEvent);
// If handled, then stop propagation of event in DOM
if (flag) oEvent.stopPropagation();
var file = oEvent.dataTransfer.files[0];
var reader = new FileReader();
reader.onload = (function (theFile) {
return function (e) {
agControl.Content.mySLapp.Drop(oEvent.x, oEvent.y, theFile.name, new Uint8Array(e.target.result));
};
})(file);
reader.readAsArrayBuffer(file);
}
And the c#:
public
class
ScriptableDropHandler
{
[ScriptableMember]
public
void
Drop(
object
x,
object
y,
object
name,
object
args)
{
var scriptObject = args
as
ScriptObject;
if
(scriptObject !=
null
)
{
var length = scriptObject.GetProperty(
"length"
);
var intLength = Convert.ToInt32(length);
var bytes =
new
byte
[intLength];
for
(var i = 0; i < bytes.Length; i++)
{
bytes[i] = Convert.ToByte(scriptObject.GetProperty(i));
}
var elements = VisualTreeHelper.FindElementsInHostCoordinates(
new
Point((
double
)x, (
double
)y), Application.Current.RootVisual);
foreach
(var element
in
elements)
{
var handler = FileDropHandlerBehavior.GetFileDropHandler(element);
if
(handler !=
null
)
{
handler.Accept(
new
FileDropArgs
{
Source = element,
FileDropInfos =
new
[] {
new
FileDropInfo
{
Name = name
as
string
,
Contents = bytes
}}
});
break
;
}
}
}
}
If I remember correctly though, I think a recent update to Mac/Safari has broken something and I've not had a chance to investigate.
0

Cavit
Top achievements
Rank 1
answered on 05 May 2015, 11:06 AM
Thanks a lot for thre replies.