static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (action != GLFW_PRESS) return; switch (key) { case GLFW_KEY_ESCAPE: glfwSetWindowShouldClose(window, GLFW_TRUE); break; case GLFW_KEY_V: if (mods == MODIFIER) { const char* string; string = glfwGetClipboardString(window); if (string) printf("Clipboard contains \"%s\"\n", string); else printf("Clipboard does not contain a string\n"); } break; case GLFW_KEY_C: if (mods == MODIFIER) { const char* string = "Hello GLFW World!"; glfwSetClipboardString(window, string); printf("Setting clipboard to \"%s\"\n", string); } break; } }
static void key_callback(GLFWwindow window, int key, int action) { if (action != GLFW_PRESS) return; switch (key) { case GLFW_KEY_ESCAPE: glfwCloseWindow(window); break; case GLFW_KEY_V: if (control_is_down(window)) { const char* string; string = glfwGetClipboardString(window); if (string) printf("Clipboard contains \"%s\"\n", string); else printf("Clipboard does not contain a string\n"); } break; case GLFW_KEY_C: if (control_is_down(window)) { const char* string = "Hello GLFW World!"; glfwSetClipboardString(window, string); printf("Setting clipboard to \"%s\"\n", string); } break; } }
void TextBox::pasteFromClipboard() { Screen *sc = dynamic_cast<Screen *>(this->window()->parent()); if (!sc) return; const char* cbstr = glfwGetClipboardString(sc->glfwWindow()); if (cbstr) mValueTemp.insert(mCursorPos, std::string(cbstr)); }
JNIEXPORT jstring JNICALL Java_com_badlogic_jglfw_Glfw_glfwGetClipboardString(JNIEnv* env, jclass clazz, jlong window) { //@line:889 return env->NewStringUTF(glfwGetClipboardString((GLFWwindow*)window)); }
bool TBClipboard::GetText(TBStr &text) { if (GLFWwindow *window = glfwGetCurrentContext()) { if (const char *str = glfwGetClipboardString(window)) return text.Set(str); } return false; }
const char* kit::UISystem::__imgui_getClipboardText() { kit::Window::Ptr win = kit::UISystem::m_window.lock(); if (win) { return glfwGetClipboardString(win->getGLFWHandle()); } static const char * woot = ""; return woot; }
string ofxTextInputField::getClipboard() { const char *clip = glfwGetClipboardString((GLFWwindow*) ofGetWindowPtr()->getCocoaWindow()); if(clip!=NULL) { return string(clip); } else { return ""; } }
bool TBClipboard::HasText() { if (GLFWwindow *window = glfwGetCurrentContext()) { const char *str = glfwGetClipboardString(window); if (str && *str) return true; } return false; }
void Visualizer::CopyViewStatusFromClipboard() { const char *clipboard_string_buffer = glfwGetClipboardString( window_); if (clipboard_string_buffer != NULL) { std::string clipboard_string(clipboard_string_buffer); ViewTrajectory trajectory; if (ReadIJsonConvertibleFromJSONString(clipboard_string, trajectory) == false) { PrintInfo("Something is wrong copying view status.\n"); return; } if (trajectory.view_status_.size() != 1) { PrintInfo("Something is wrong copying view status.\n"); return; } view_control_ptr_->ConvertFromViewParameters( trajectory.view_status_[0]); } }
static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data) { return glfwGetClipboardString((GLFWwindow*)user_data); }
// NB: ImGui already provide OS clipboard support for Windows so this isn't needed if you are using Windows only. static const char* ImImpl_GetClipboardTextFn() { return glfwGetClipboardString(window); }
// NB: ImGui already provide OS clipboard support for Windows so this isn't needed if you are using Windows only. const char *kl::GuiManager::ImImpl_GetClipboardTextFn() { return glfwGetClipboardString( g_Window ); }
void TextFieldWidget::ProcessEvent(InputEvent & InputEvent) { // DECISION //if (CheckHover()) // HACK //if (HasTypingFocus()) /*{ // TEST if ( InputEvent.m_EventTypes.end() != InputEvent.m_EventTypes.find(InputEvent::EventType::POINTER_ACTIVATION) && ( InputEvent.m_EventTypes.end() != InputEvent.m_EventTypes.find(InputEvent::EventType::BUTTON_EVENT) && 0 == InputEvent.m_InputId && true == InputEvent.m_Buttons[0])) { InputEvent.m_Pointer->ModifyPointerMapping().RequestPointerCapture(&ModifyGestureRecognizer()); } } // DECISION // TEST // If captured by something else, ignore this event if ( nullptr != InputEvent.m_Pointer->GetPointerMapping().GetCapturer() && &GetGestureRecognizer() != InputEvent.m_Pointer->GetPointerMapping().GetCapturer()) { return; }*/ auto SelectionLength = std::max(m_CaretPosition, m_SelectionPosition) - std::min(m_CaretPosition, m_SelectionPosition); if (InputEvent.m_EventTypes.end() != InputEvent.m_EventTypes.find(InputEvent::EventType::BUTTON_EVENT)) { auto ButtonId = InputEvent.m_InputId; bool Pressed = InputEvent.m_Buttons[0]; // TODO: Check if there are >1 buttons if (Pointer::VirtualCategory::TYPING == InputEvent.m_Pointer->GetVirtualCategory()) { if (Pressed) { auto ShiftActive = ( InputEvent.m_Pointer->GetPointerState().GetButtonState(GLFW_KEY_LSHIFT) || InputEvent.m_Pointer->GetPointerState().GetButtonState(GLFW_KEY_RSHIFT)); auto SuperActive = ( InputEvent.m_Pointer->GetPointerState().GetButtonState(GLFW_KEY_LSUPER) || InputEvent.m_Pointer->GetPointerState().GetButtonState(GLFW_KEY_RSUPER)); auto AltActive = ( InputEvent.m_Pointer->GetPointerState().GetButtonState(GLFW_KEY_LALT) || InputEvent.m_Pointer->GetPointerState().GetButtonState(GLFW_KEY_RALT)); bool HandledEvent = true; // Assume true at first switch (ButtonId) { case GLFW_KEY_BACKSPACE: { auto SelectionExisted = EraseSelectionIfAny(); if (false == SelectionExisted) { if (m_CaretPosition > 0) { m_Content.erase(m_CaretPosition - 1, 1); UpdateContentLines(); MoveCaret(-1, true); } } } break; case GLFW_KEY_DEL: { auto SelectionExisted = EraseSelectionIfAny(); if (false == SelectionExisted) { if (m_CaretPosition < m_Content.length()) { m_Content.erase(m_CaretPosition, 1); UpdateContentLines(); } } } break; case GLFW_KEY_ENTER: case GLFW_KEY_KP_ENTER: { EraseSelectionIfAny(); m_Content.insert(m_CaretPosition, 1, '\n'); UpdateContentLines(); MoveCaret(+1, true); } break; case GLFW_KEY_TAB: { EraseSelectionIfAny(); m_Content.insert(m_CaretPosition, 1, '\t'); UpdateContentLines(); MoveCaret(+1, true); } break; case GLFW_KEY_LEFT: { if (0 != SelectionLength && !ShiftActive) { SetCaretPosition(std::min(m_CaretPosition, m_SelectionPosition), true); } else { if (SuperActive && !AltActive) { std::vector<class ContentLine>::size_type LineNumber = 0; std::vector<class ContentLine>::size_type ColumnNumber = 0; for (auto & ContentLine : m_ContentLines) { if (ContentLine.m_StartPosition + ContentLine.m_Length >= m_CaretPosition) { ColumnNumber = m_CaretPosition - ContentLine.m_StartPosition; break; } ++LineNumber; } SetCaretPosition(m_ContentLines[LineNumber].m_StartPosition, !ShiftActive); } else if (AltActive && !SuperActive) { { // Skip spaces to the left auto LookAt = m_CaretPosition - 1; while ( LookAt != -1 && !IsCoreCharacter(m_Content[LookAt])) { --LookAt; } // Skip non-spaces to the left while ( LookAt != -1 && IsCoreCharacter(m_Content[LookAt])) { --LookAt; } SetCaretPosition(LookAt + 1, !ShiftActive); } } else { MoveCaretTry(-1, !ShiftActive); } } } break; case GLFW_KEY_RIGHT: { if (0 != SelectionLength && !ShiftActive) { SetCaretPosition(std::max(m_CaretPosition, m_SelectionPosition), true); } else { if (SuperActive && !AltActive) { std::vector<class ContentLine>::size_type LineNumber = 0; std::vector<class ContentLine>::size_type ColumnNumber = 0; for (auto & ContentLine : m_ContentLines) { if (ContentLine.m_StartPosition + ContentLine.m_Length >= m_CaretPosition) { ColumnNumber = m_CaretPosition - ContentLine.m_StartPosition; break; } ++LineNumber; } SetCaretPosition(m_ContentLines[LineNumber].m_StartPosition + m_ContentLines[LineNumber].m_Length, !ShiftActive); } else if (AltActive && !SuperActive) { { // Skip spaces to the right auto LookAt = m_CaretPosition; while ( LookAt < m_Content.length() && !IsCoreCharacter(m_Content[LookAt])) { ++LookAt; } // Skip non-spaces to the right while ( LookAt < m_Content.length() && IsCoreCharacter(m_Content[LookAt])) { ++LookAt; } SetCaretPosition(LookAt, !ShiftActive); } } else { MoveCaretTry(+1, !ShiftActive); } } } break; case GLFW_KEY_UP: { if (0 != SelectionLength && !ShiftActive) { SetCaretPosition(std::min(m_CaretPosition, m_SelectionPosition), true); } if (SuperActive) { SetCaretPosition(0, !ShiftActive); // Go to home } else { MoveCaretVerticallyTry(-1, !ShiftActive); } } break; case GLFW_KEY_DOWN: { if (0 != SelectionLength && !ShiftActive) { SetCaretPosition(std::max(m_CaretPosition, m_SelectionPosition), true); } if (SuperActive) { SetCaretPosition(m_Content.length(), !ShiftActive); // Go to end } else { MoveCaretVerticallyTry(+1, !ShiftActive); } } break; case 'A': { if (SuperActive) { // Select all SetCaretPosition(0, true); SetCaretPosition(m_Content.length(), false); } } break; case 'X': { if (SuperActive) { if (!GetSelectionContent().empty()) { #if DECISION_USE_CLIPBOARD_INSTEAD_OF_TypingModule glfwSetClipboardString(GetSelectionContent()); #else m_TypingModule.SetString(GetSelectionContent()); #endif EraseSelectionIfAny(); } } } break; case 'C': { if (SuperActive) { if (!GetSelectionContent().empty()) { #if DECISION_USE_CLIPBOARD_INSTEAD_OF_TypingModule glfwSetClipboardString(GetSelectionContent()); #else m_TypingModule.SetString(GetSelectionContent()); #endif } } } break; case 'V': { if (SuperActive) { if (!glfwGetClipboardString().empty()) { EraseSelectionIfAny(); #if DECISION_USE_CLIPBOARD_INSTEAD_OF_TypingModule m_Content.insert(m_CaretPosition, glfwGetClipboardString()); UpdateContentLines(); MoveCaret(static_cast<sint32>(glfwGetClipboardString().length()), true); #else auto Entry = m_TypingModule.TakeString(); m_Content.insert(m_CaretPosition, Entry); UpdateContentLines(); MoveCaret(static_cast<sint32>(Entry.length()), true); #endif } } } break; default: HandledEvent = false; break; } if (HandledEvent) { InputEvent.m_Handled = true; } } } else if (Pointer::VirtualCategory::POINTING == InputEvent.m_Pointer->GetVirtualCategory()) { if (Pressed) { switch (ButtonId) { case 0: { Vector2n GlobalPosition(InputEvent.m_Pointer->GetPointerState().GetAxisState(0).GetPosition(), InputEvent.m_Pointer->GetPointerState().GetAxisState(1).GetPosition()); Vector2n LocalPosition = GlobalToLocal(GlobalPosition); LocalPosition = m_TypingModule.GetInsertionPosition(LocalPosition); auto CaretPosition = GetNearestCaretPosition(LocalPosition); auto ShiftActive = g_InputManager->m_TypingPointer->GetPointerState().GetButtonState(GLFW_KEY_LSHIFT) || g_InputManager->m_TypingPointer->GetPointerState().GetButtonState(GLFW_KEY_RSHIFT); SetCaretPosition(CaretPosition, !ShiftActive); { auto Entry = m_TypingModule.TakeString(); if (!Entry.empty()) { m_Content.insert(m_CaretPosition, Entry); UpdateContentLines(); SetCaretPosition(GetNearestCaretPosition(LocalPosition), true); } } } break; default: break; } } } } if ( InputEvent.m_EventTypes.end() != InputEvent.m_EventTypes.find(InputEvent::EventType::AXIS_EVENT) || InputEvent.m_EventTypes.end() != InputEvent.m_EventTypes.find(InputEvent::EventType::CANVAS_MOVED_TEST)) { if (Pointer::VirtualCategory::POINTING == InputEvent.m_Pointer->GetVirtualCategory()) { if (true == InputEvent.m_Pointer->GetPointerState().GetButtonState(0)) { Vector2n GlobalPosition(InputEvent.m_Pointer->GetPointerState().GetAxisState(0).GetPosition(), InputEvent.m_Pointer->GetPointerState().GetAxisState(1).GetPosition()); Vector2n LocalPosition = GlobalToLocal(GlobalPosition); auto CaretPosition = GetNearestCaretPosition(LocalPosition); SetCaretPosition(CaretPosition, false); } } } }
static int ui_input_key(struct input *input) { switch (ui.key) { case KEY_LEFT: if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT) { input->q = prev_word(input->q, input->text); } else if (ui.mod == GLFW_MOD_CONTROL) { if (input->p != input->q) input->p = input->q = input->p < input->q ? input->p : input->q; else input->p = input->q = prev_word(input->q, input->text); } else if (ui.mod == GLFW_MOD_SHIFT) { if (input->q > input->text) input->q = prev_char(input->q, input->text); } else if (ui.mod == 0) { if (input->p != input->q) input->p = input->q = input->p < input->q ? input->p : input->q; else if (input->q > input->text) input->p = input->q = prev_char(input->q, input->text); } break; case KEY_RIGHT: if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT) { input->q = next_word(input->q, input->end); } else if (ui.mod == GLFW_MOD_CONTROL) { if (input->p != input->q) input->p = input->q = input->p > input->q ? input->p : input->q; else input->p = input->q = next_word(input->q, input->end); } else if (ui.mod == GLFW_MOD_SHIFT) { if (input->q < input->end) input->q = next_char(input->q); } else if (ui.mod == 0) { if (input->p != input->q) input->p = input->q = input->p > input->q ? input->p : input->q; else if (input->q < input->end) input->p = input->q = next_char(input->q); } break; case KEY_UP: case KEY_HOME: if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT) { input->q = input->text; } else if (ui.mod == GLFW_MOD_CONTROL) { input->p = input->q = input->text; } else if (ui.mod == GLFW_MOD_SHIFT) { input->q = input->text; } else if (ui.mod == 0) { input->p = input->q = input->text; } break; case KEY_DOWN: case KEY_END: if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT) { input->q = input->end; } else if (ui.mod == GLFW_MOD_CONTROL) { input->p = input->q = input->end; } else if (ui.mod == GLFW_MOD_SHIFT) { input->q = input->end; } else if (ui.mod == 0) { input->p = input->q = input->end; } break; case KEY_DELETE: if (input->p != input->q) ui_input_delete_selection(input); else if (input->p < input->end) { char *np = next_char(input->p); memmove(input->p, np, input->end - np); input->end -= np - input->p; *input->end = 0; input->q = input->p; } break; case KEY_ESCAPE: return -1; case KEY_ENTER: return 1; case KEY_BACKSPACE: if (input->p != input->q) ui_input_delete_selection(input); else if (input->p > input->text) { char *pp = prev_char(input->p, input->text); memmove(pp, input->p, input->end - input->p); input->end -= input->p - pp; *input->end = 0; input->q = input->p = pp; } break; case KEY_CTL_A: input->p = input->q = input->text; break; case KEY_CTL_E: input->p = input->q = input->end; break; case KEY_CTL_W: if (input->p != input->q) ui_input_delete_selection(input); else { input->p = prev_word(input->p, input->text); ui_input_delete_selection(input); } break; case KEY_CTL_U: input->p = input->q = input->end = input->text; break; case KEY_CTL_C: case KEY_CTL_X: if (input->p != input->q) { char buf[sizeof input->text]; char *p = input->p < input->q ? input->p : input->q; char *q = input->p > input->q ? input->p : input->q; memmove(buf, p, q - p); buf[q-p] = 0; glfwSetClipboardString(window, buf); if (ui.key == KEY_CTL_X) ui_input_delete_selection(input); } break; case KEY_CTL_V: { const char *buf = glfwGetClipboardString(window); if (buf) ui_input_paste(input, buf, (int)strlen(buf)); } break; default: if (ui.key >= 32) { int cat = ucdn_get_general_category(ui.key); if (ui.key == ' ' || (cat >= UCDN_GENERAL_CATEGORY_LL && cat < UCDN_GENERAL_CATEGORY_ZL)) { char buf[8]; int n = fz_runetochar(buf, ui.key); ui_input_paste(input, buf, n); } } break; } return 0; }
void TextBox::pasteFromClipboard() { ref<Screen> sc = dynamic_pointer_cast<Screen>(this->window()->parent()); std::string str(glfwGetClipboardString(sc->glfwWindow())); mValueTemp.insert(mCursorPos, str); }
static const c08* InterfaceGetClipboardText() { return glfwGetClipboardString(GlobalWindow); }
static const char* ImGui_ImplGlfw_GetClipboardText(void* userData) { return glfwGetClipboardString(g_Window); }
void GLViewImpl::onGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { if (GLFW_REPEAT != action) { EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action); auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&event); } if (GLFW_RELEASE != action) { switch (g_keyCodeMap[key]) { case EventKeyboard::KeyCode::KEY_BACKSPACE: IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); break; case EventKeyboard::KeyCode::KEY_DELETE: IMEDispatcher::sharedDispatcher()->dispatchDeleteForward(); break; case EventKeyboard::KeyCode::KEY_LEFT_ARROW: IMEDispatcher::sharedDispatcher()->dispatchMoveCursorBackward((mods & GLFW_MOD_CONTROL) != 0, (mods & GLFW_MOD_SHIFT) != 0); break; case EventKeyboard::KeyCode::KEY_RIGHT_ARROW: IMEDispatcher::sharedDispatcher()->dispatchMoveCursorForward((mods & GLFW_MOD_CONTROL) != 0, (mods & GLFW_MOD_SHIFT) != 0); break; case EventKeyboard::KeyCode::KEY_HOME: IMEDispatcher::sharedDispatcher()->dispatchMoveCursorHome((mods & GLFW_MOD_SHIFT) != 0); break; case EventKeyboard::KeyCode::KEY_END: IMEDispatcher::sharedDispatcher()->dispatchMoveCursorEnd((mods & GLFW_MOD_SHIFT) != 0); break; case EventKeyboard::KeyCode::KEY_CAPITAL_A: case EventKeyboard::KeyCode::KEY_A: if ((mods & GLFW_MOD_CONTROL) != 0) { IMEDispatcher::sharedDispatcher()->dispatchSelectAllText(); } break; case EventKeyboard::KeyCode::KEY_CAPITAL_C: case EventKeyboard::KeyCode::KEY_C: if ((mods & GLFW_MOD_CONTROL) != 0) { std::string text = IMEDispatcher::sharedDispatcher()->getSelectedText(); if (!text.empty()) { glfwSetClipboardString(window, text.c_str()); } } break; case EventKeyboard::KeyCode::KEY_CAPITAL_X: case EventKeyboard::KeyCode::KEY_X: if ((mods & GLFW_MOD_CONTROL) != 0) { std::string text = IMEDispatcher::sharedDispatcher()->getSelectedText(); if (!text.empty()) { glfwSetClipboardString(window, text.c_str()); IMEDispatcher::sharedDispatcher()->dispatchDeleteForward(); } } break; case EventKeyboard::KeyCode::KEY_CAPITAL_V: case EventKeyboard::KeyCode::KEY_V: if ((mods & GLFW_MOD_CONTROL) != 0) { const char* text = glfwGetClipboardString(window); if (text) { IMEDispatcher::sharedDispatcher()->dispatchInsertText(text, strlen(text)); } } break; default: break; } } }
string CWindow::GetClipboardText() const { return glfwGetClipboardString(WindowHandle); }
static const char* GetClipboardText() { return glfwGetClipboardString(g_Window); }
static const char* ImGui_ImplGlfwGL3_GetClipboardText() { return glfwGetClipboardString(g_Window); }
const char* call(GLFWwindow* window) { return glfwGetClipboardString(window); }