ui/winui/table.cpp

branch
newapi
changeset 221
a82d9beaa94a
parent 218
d06e7e8e53e1
child 223
8d7ca1b320e2
--- a/ui/winui/table.cpp	Tue Oct 17 21:50:48 2023 +0200
+++ b/ui/winui/table.cpp	Thu Oct 19 18:30:19 2023 +0200
@@ -41,6 +41,8 @@
 #include <winrt/Microsoft.UI.Xaml.Media.h>
 #include <winrt/Microsoft.UI.Xaml.Input.h>
 #include <winrt/Windows.UI.Core.h>
+#include <winrt/Windows.ApplicationModel.h>
+#include <winrt/Windows.ApplicationModel.DataTransfer.h>
 
 using namespace winrt;
 using namespace Microsoft::UI::Xaml;
@@ -76,6 +78,13 @@
 	uitable->onselectiondata = args.onselectiondata;
 	uitable->onactivate = args.onactivate;
 	uitable->onactivatedata = args.onactivatedata;
+	uitable->ondragstart = args.ondragstart;
+	uitable->ondragstartdata = args.ondragstartdata;
+	uitable->ondragcomplete = args.ondragcomplete;
+	uitable->ondrop = args.ondrop;
+	uitable->ondropdata = args.ondropsdata;
+	uitable->enabledrag = args.enabledrag;
+	uitable->enabledrop = args.enabledrop;
 
 	// grid styling
 	winrt::Windows::UI::Color bg = { 255, 255, 255, 255 }; // test color
@@ -259,6 +268,17 @@
 				cellBorder.BorderThickness(b2);
 			}
 
+			// dnd
+			if (enabledrag) {
+				cellBorder.CanDrag(enabledrag);
+				cellBorder.DragStarting([](IInspectable const& sender, DragStartingEventArgs args) {
+					//args.Data().SetText(L"test");
+					});
+			}
+			if (enabledrop) {
+				cellBorder.AllowDrop(enabledrop);
+			}
+
 			// set the cell value
 			// depending on the type, we create different cell controls
 			UiModelType type = model->types[col];
@@ -269,6 +289,7 @@
 					cell.VerticalAlignment(VerticalAlignment::Stretch);
 					textblock_set_str(cell, (char*)getvalue(elm, model_col));
 					cellBorder.Child(cell);
+
 					break;
 				}
 				case UI_INTEGER: {

mercurial