Skip to content

Commit

Permalink
Apply clean code for Drag and Drop
Browse files Browse the repository at this point in the history
  • Loading branch information
taehyub committed Sep 10, 2024
1 parent 5b6c04b commit 6da3324
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
22 changes: 3 additions & 19 deletions src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public void StartDragAndDrop(View sourceView, View shadowView, DragData dragData
string [] mimeTypes;
string [] dataSet;

if (string.IsNullOrEmpty(dragData.MimeType))
if (string.IsNullOrEmpty(dragData.MimeType) && dragData.DataMap != null)
{
mimeTypes = dragData.DataMap.Keys.ToArray();
dataSet = dragData.DataMap.Values.ToArray();
Expand Down Expand Up @@ -287,15 +287,7 @@ public void StartDragAndDrop(View sourceView, View shadowView, DragData dragData
/// <since_tizen> 10 </since_tizen>
public void AddListener(View targetView, DragAndDropEventHandler callback)
{
InternalDragAndDropEventHandler cb = (navtiveDragEvent) => ProcessDragEventTargetCallback(navtiveDragEvent, targetView, callback);

targetEventDictionary.Add(targetView, cb);

if (!Interop.DragAndDrop.AddListener(SwigCPtr, View.getCPtr(targetView), "*/*",
new global::System.Runtime.InteropServices.HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(cb))))
{
throw new InvalidOperationException("Fail to AddListener for View");
}
AddListener(targetView, "*/*", callback);
}

/// <summary>
Expand Down Expand Up @@ -348,15 +340,7 @@ public void RemoveListener(View targetView, DragAndDropEventHandler _)
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddListener(Window targetWindow, DragAndDropWindowEventHandler callback)
{
InternalDragAndDropEventHandler cb = (navtiveDragEvent) => ProcessDragEventWindowCallback(navtiveDragEvent, targetWindow, callback);

targetWindowEventDictionary.Add(targetWindow, cb);

if (!Interop.DragAndDrop.WindowAddListener(SwigCPtr, Window.getCPtr(targetWindow), "*/*",
new global::System.Runtime.InteropServices.HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(cb))))
{
throw new InvalidOperationException("Fail to AddListener for Window");
}
AddListener(targetWindow, "*/*", callback);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion test/NUIDnDMultiWindow/NUIDnDMultiWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void Initialize()
Tizen.Log.Debug("NUIDnDMultiWindow", "StartDragAndDrop");
shadowView = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.SharedResource + "dragsource.png");
shadowView.Size = new Size(150, 150);
DragData dragData;
DragData dragData = new DragData();
dragData.MimeType = "text/uri-list";
dragData.Data = Tizen.Applications.Application.Current.DirectoryInfo.SharedResource + "dragsource.png";
dnd.StartDragAndDrop(sourceView, shadowView, dragData, OnSourceApp_SourceFunc);
Expand Down
2 changes: 1 addition & 1 deletion test/NUIDnDSource/NUIDnDSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void Initialize()
Tizen.Log.Debug("NUIDnDSource", "StartDragAndDrop");
shadowView = new ImageView(Tizen.Applications.Application.Current.DirectoryInfo.SharedResource + "dragsource.png");
shadowView.Size = new Size(150, 150);
DragData dragData;
DragData dragData = new DragData();
dragData.MimeType = "text/uri-list";
dragData.Data = Tizen.Applications.Application.Current.DirectoryInfo.SharedResource + "dragsource.png";
dnd.StartDragAndDrop(sourceView, shadowView, dragData, OnSourceEventFunc);
Expand Down

0 comments on commit 6da3324

Please sign in to comment.