diff --git a/dev/VoxelEngine.png b/dev/VoxelEngine.png index 68924547..0d69ae74 100644 Binary files a/dev/VoxelEngine.png and b/dev/VoxelEngine.png differ diff --git a/src/frontend/gui/controls.cpp b/src/frontend/gui/controls.cpp index 95ebf1c1..b4445d2f 100644 --- a/src/frontend/gui/controls.cpp +++ b/src/frontend/gui/controls.cpp @@ -2,6 +2,7 @@ #include +#include "../../window/Events.h" #include "../../assets/Assets.h" #include "../../graphics/Batch2D.h" #include "../../graphics/Font.h" @@ -21,7 +22,9 @@ const uint KEY_BACKSPACE = 259; using namespace gui; Label::Label(wstring text, string fontName) - : UINode(vec2(), vec2(text.length() * 8, 15)), text_(text), fontName_(fontName) { + : UINode(vec2(), vec2(text.length() * 8, 15)), + text_(text), + fontName_(fontName) { } Label& Label::text(wstring text) { @@ -175,6 +178,13 @@ void TextBox::keyPressed(int key) { defocus(); break; } + // Pasting text from clipboard + if (key == keycode::V && Events::pressed(keycode::LEFT_CONTROL)) { + const char* text = Window::getClipboardText(); + if (text) { + input += util::str2wstr_utf8(text); + } + } } shared_ptr TextBox::getAt(vec2 pos, shared_ptr self) { diff --git a/src/window/Window.cpp b/src/window/Window.cpp index 856479b5..2e8344b0 100644 --- a/src/window/Window.cpp +++ b/src/window/Window.cpp @@ -298,6 +298,10 @@ ImageData* Window::takeScreenshot() { return new ImageData(ImageFormat::rgb888, width, height, data); } +const char* Window::getClipboardText() { + return glfwGetClipboardString(window); +} + bool Window::tryToMaximize(GLFWwindow* window, GLFWmonitor* monitor) { glm::ivec4 windowFrame(0); glm::ivec4 workArea(0); diff --git a/src/window/Window.h b/src/window/Window.h index b4bb8786..4fb7ed34 100644 --- a/src/window/Window.h +++ b/src/window/Window.h @@ -49,6 +49,7 @@ public: static void clearDepth(); static void setBgColor(glm::vec3 color); static double time(); + static const char* getClipboardText(); static DisplaySettings* getSettings(); static glm::vec2 size() {