Pasting text from clipboard
This commit is contained in:
parent
73595cd558
commit
0f1aabf200
Binary file not shown.
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 124 KiB |
@ -2,6 +2,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#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<UINode> TextBox::getAt(vec2 pos, shared_ptr<UINode> self) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user