瀏覽代碼

callback test

Hongtae Kim 8 年之前
父節點
當前提交
97d961854b
共有 1 個檔案被更改,包括 10 行新增30 行删除
  1. 10
    30
      TestApp1/TestApp1.cpp

+ 10
- 30
TestApp1/TestApp1.cpp 查看文件

@@ -17,8 +17,16 @@ public:
17 17
 		DKLog("%s", DKGL_FUNCTION_NAME);
18 18
 		DKWindow::WindowCallback cb = {};
19 19
 
20
-		cb.filesDropped = DKFunction([](DKWindow*, const DKPoint&, const DKWindow::WindowCallback::StringArray&) {
21
-			DKLog("cb.filesDropped");
20
+		cb.draggingFeedback = DKFunction([](DKWindow*, DKWindow::DraggingState state, const DKPoint&, const DKStringArray&) {
21
+			DKLog("cb.draggingFeedback: state:%d", state);
22
+			return DKWindow::DragOperationCopy;
23
+		});
24
+		cb.closeRequest = DKFunction([](DKWindow* window)
25
+		{
26
+			DKLog("Close request?");
27
+			if (DKIsDebuggerPresent())
28
+				return false;
29
+			return true;
22 30
 		});
23 31
 
24 32
 		window = DKWindow::Create("DefaultWindow", 
@@ -30,42 +38,14 @@ public:
30 38
 		window->AddEventHandler(this,
31 39
 			DKFunction([this](const DKWindow::WindowEvent& e)
32 40
 			{
33
-				DKLog("WindowEvent: %d, origin:(%.1f, %.1f), size:(%.1f x %.1f), content:(%.1f, %.1f), scale:%f",
34
-					  e.type,
35
-					  e.windowRect.origin.x, e.windowRect.origin.y,
36
-					  e.windowRect.size.width, e.windowRect.size.height,
37
-					  e.contentRect.size.width, e.contentRect.size.height,
38
-					  e.contentScaleFactor);
39 41
 				if (e.type == DKWindow::WindowEvent::WindowClosed)
40 42
 					DKApplication::Instance()->Terminate(0);
41 43
 			}),
42 44
 			DKFunction([this](const DKWindow::KeyboardEvent& e)
43 45
 			{
44
-				if (e.type == DKWindow::KeyboardEvent::KeyUp)
45
-				{
46
-					if (e.key == DKVK_ENTER || e.key == DKVK_RETURN)
47
-					{
48
-						window->SetTextInputEnabled(0, !window->IsTextInputEnabled(0));
49
-						DKLog("TextInput: %d", window->IsTextInputEnabled(0));
50
-					}
51
-					else if (e.key == DKVK_ESCAPE)
52
-					{
53
-						window->HoldMouse(0, !window->IsMouseHeld(0));
54
-						DKLog("HoldMouse: %d", window->IsMouseHeld(0));
55
-					}
56
-				}
57
-				DKLog("KeyboardEvent: %d, %ls, %ls",
58
-					  e.type,
59
-					  (const wchar_t*)DKWindow::GetVKName(e.key),
60
-					  (const wchar_t*)e.text);
61 46
 			}),
62 47
 			DKFunction([this](const DKWindow::MouseEvent& e)
63 48
 			{
64
-				if (e.type != DKWindow::MouseEvent::Move || window->IsMouseHeld(0))
65
-				{
66
-					DKLog("MouseEvent: %d, btn:%d, location:%.1f, %.1f, delta:%.1f, %.1f",
67
-						e.type, e.buttonId, e.location.x, e.location.y, e.delta.x, e.delta.y);
68
-				}
69 49
 			})
70 50
 		);
71 51
 	}