From da164f04c91a03062b9991d5c3afc320408c5d8c Mon Sep 17 00:00:00 2001 From: GameParrot <85067619+GameParrot@users.noreply.github.com> Date: Mon, 6 Jan 2025 11:32:12 -0500 Subject: [PATCH] allow dragging and dropping to import (#113) --- src/window_callbacks.cpp | 4 ++++ src/window_callbacks.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/window_callbacks.cpp b/src/window_callbacks.cpp index 14e460bb..cd6fbee6 100644 --- a/src/window_callbacks.cpp +++ b/src/window_callbacks.cpp @@ -52,6 +52,7 @@ void WindowCallbacks::registerCallbacks() { window.setTouchEndCallback(std::bind(&WindowCallbacks::onTouchEnd, this, _1, _2, _3)); window.setKeyboardCallback(std::bind(&WindowCallbacks::onKeyboard, this, _1, _2)); window.setKeyboardTextCallback(std::bind(&WindowCallbacks::onKeyboardText, this, _1)); + window.setDropCallback(std::bind(&WindowCallbacks::onDrop, this, _1)); window.setPasteCallback(std::bind(&WindowCallbacks::onPaste, this, _1)); window.setGamepadStateCallback(std::bind(&WindowCallbacks::onGamepadState, this, _1, _2)); window.setGamepadButtonCallback(std::bind(&WindowCallbacks::onGamepadButton, this, _1, _2, _3)); @@ -591,6 +592,9 @@ void WindowCallbacks::onKeyboardText(std::string const& c) { else jniSupport.getTextInputHandler().onTextInput(c); } +void WindowCallbacks::onDrop(std::string const &path) { + jniSupport.importFile(path); +} void WindowCallbacks::onPaste(std::string const& str) { #ifdef USE_IMGUI Settings::clipboard = str; diff --git a/src/window_callbacks.h b/src/window_callbacks.h index 49c3a3e8..36bf7af4 100644 --- a/src/window_callbacks.h +++ b/src/window_callbacks.h @@ -106,6 +106,7 @@ class WindowCallbacks { void onTouchEnd(int id, double x, double y); void onKeyboard(KeyCode key, KeyAction action); void onKeyboardText(std::string const &c); + void onDrop(std::string const &path); void onPaste(std::string const &str); void onGamepadState(int gamepad, bool connected); void onGamepadButton(int gamepad, GamepadButtonId btn, bool pressed);