// TestApp1.cpp : Defines the entry point for the application. // #ifdef _WIN32 #include "Win32/stdafx.h" #endif #include class TestApp1 : public DKApplication { DKObject window; public: void OnInitialize(void) override { DKLog("%s", DKGL_FUNCTION_NAME); window = DKWindow::Create("DefaultWindow"); window->Activate(); window->AddEventHandler(this, DKFunction([this](const DKWindow::WindowEvent& e) { DKLog("WindowEvent: %d, origin:(%.1f, %.1f), size:(%.1f x %.1f), content:(%.1f, %.1f), scale:%f", e.type, e.windowRect.origin.x, e.windowRect.origin.y, e.windowRect.size.width, e.windowRect.size.height, e.contentRect.size.width, e.contentRect.size.height, e.contentScaleFactor); if (e.type == DKWindow::WindowEvent::WindowClosed) DKApplication::Instance()->Terminate(0); }), DKFunction([this](const DKWindow::KeyboardEvent& e) { if (e.type == DKWindow::KeyboardEvent::KeyUp) { if (e.key == DKVK_ENTER || e.key == DKVK_RETURN) { window->SetTextInputEnabled(0, !window->IsTextInputEnabled(0)); DKLog("TextInput: %d", window->IsTextInputEnabled(0)); } else if (e.key == DKVK_ESCAPE) { window->HoldMouse(0, !window->IsMouseHeld(0)); DKLog("HoldMouse: %d", window->IsMouseHeld(0)); } } DKLog("KeyboardEvent: %d, %ls, %ls", e.type, (const wchar_t*)DKWindow::GetVKName(e.key), (const wchar_t*)e.text); }), DKFunction([this](const DKWindow::MouseEvent& e) { //DKLog("MouseEvent: %d, btn:%d, location:%.1f, %.1f, delta:%.1f, %.1f", // e.type, e.buttonId, e.location.x, e.location.y, e.delta.x, e.delta.y); }) ); } void OnTerminate(void) override { DKLog("%s", DKGL_FUNCTION_NAME); } }; #ifdef _WIN32 int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) #else int main(int argc, const char * argv[]) #endif { TestApp1 app; DKPropertySet::SystemConfig().SetValue("AppDelegate", "AppDelegate"); return app.Run(); }