Browse Source

callback test

Hongtae Kim 8 years ago
parent
commit
97d961854b
1 changed files with 10 additions and 30 deletions
  1. 10
    30
      TestApp1/TestApp1.cpp

+ 10
- 30
TestApp1/TestApp1.cpp View File

17
 		DKLog("%s", DKGL_FUNCTION_NAME);
17
 		DKLog("%s", DKGL_FUNCTION_NAME);
18
 		DKWindow::WindowCallback cb = {};
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
 		window = DKWindow::Create("DefaultWindow", 
32
 		window = DKWindow::Create("DefaultWindow", 
30
 		window->AddEventHandler(this,
38
 		window->AddEventHandler(this,
31
 			DKFunction([this](const DKWindow::WindowEvent& e)
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
 				if (e.type == DKWindow::WindowEvent::WindowClosed)
41
 				if (e.type == DKWindow::WindowEvent::WindowClosed)
40
 					DKApplication::Instance()->Terminate(0);
42
 					DKApplication::Instance()->Terminate(0);
41
 			}),
43
 			}),
42
 			DKFunction([this](const DKWindow::KeyboardEvent& e)
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
 			DKFunction([this](const DKWindow::MouseEvent& e)
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
 	}