[global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_perform_drop")]
internal static extern int PerformDrop(IntPtr kvmService);
+ [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_cancel_drag")]
+ internal static extern int CancelDrag(IntPtr kvmService);
+
+ [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_receive_drag_data")]
+ internal static extern int ReceiveDragData(IntPtr kvmService, string mimeType);
+
[global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_secondary_selection_set")]
internal static extern int SetSecondarySelection(IntPtr kvmService);
}
/// <summary>
+ /// Requests to cancel current drag.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+ public void CancelDrag()
+ {
+ int res = Interop.KVMService.CancelDrag(_kvmService);
+ _tzsh.ErrorCodeThrow(res);
+ }
+
+ /// <summary>
+ /// Requests to receive the current drag data.
+ /// the drag data will be received by the DragEvent of the window.
+ /// </summary>
+ /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+ public void ReceiveDragData(string mimeType)
+ {
+ int res = Interop.KVMService.ReceiveDragData(_kvmService, mimeType);
+ _tzsh.ErrorCodeThrow(res);
+ }
+
+ /// <summary>
/// Requests to set KVM window as secondary selection window.
/// </summary>
/// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
windowView.BackgroundColor = Color.Yellow;
this.Add(windowView);
- dnd.AddListener(windowView, OnDnDEvent);
+ // The First argument of listener should be window, not view.
+ // The listener of view couldn't catch receive data from ReceiveDragData of KVMService
+ dnd.AddListener(this, OnDnDEvent);
tzShell = new Tizen.NUI.WindowSystem.Shell.TizenShell();
kvmService = new Tizen.NUI.WindowSystem.Shell.KVMService(tzShell, this);
if (e.DragType == DragType.Enter)
{
Log.Debug("KVMSample", "Target(KVM) App DRagEvnetType: Enter");
- kvmService.PerformDrop();
+ // PerformDrop is drop into the KVM window and finish the current drag.
+ // If you want to get the current drag data without end the drag,
+ // use ReceiveDragData(mimetype) instead of PerformDrop().
+ //kvmService.PerformDrop();
+
+ // The drag data will be received by ReceiveDragData of OnDragStarted callback and DragEvent of the OnDnDEvent callback.
+ // and the drag will be ended by enter the KVM window as UX of the app.
+ // If you want to end the drag without receive drag data, use CancelDrag().
+ kvmService.CancelDrag();
}
if (e.DragType == DragType.Drop)
{
private void OnDragStarted(object sender, EventArgs e)
{
Log.Debug("KVMSample", "Tizen KVM: Drag started");
+
+ // Request the drag data to the Display server.
+ // The drag data can get at DnD Listener (OnDnDEvent function)
+ kvmService.ReceiveDragData("text/plain");
}
private void OnDragEnded(object sender, EventArgs e)