[UI] Add paste functionality to keyboard input dialog
This commit is contained in:
committed by
Radosław Gliński
parent
0771938db6
commit
c4f1bf27ef
@@ -1099,8 +1099,23 @@ class KeyboardInputDialog : public XamDialog {
|
|||||||
if (first_draw) {
|
if (first_draw) {
|
||||||
ImGui::SetKeyboardFocusHere();
|
ImGui::SetKeyboardFocusHere();
|
||||||
}
|
}
|
||||||
if (ImGui::InputText("##body", text_buffer_.data(), text_buffer_.size(),
|
ImGui::PushID("input_text");
|
||||||
ImGuiInputTextFlags_EnterReturnsTrue)) {
|
bool input_submitted =
|
||||||
|
ImGui::InputText("##body", text_buffer_.data(), text_buffer_.size(),
|
||||||
|
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||||
|
// Context menu for paste functionality
|
||||||
|
if (ImGui::BeginPopupContextItem("input_context_menu")) {
|
||||||
|
if (ImGui::MenuItem("Paste")) {
|
||||||
|
if (ImGui::GetClipboardText() != nullptr) {
|
||||||
|
std::string clipboard_text = ImGui::GetClipboardText();
|
||||||
|
xe::string_util::copy_truncating(
|
||||||
|
text_buffer_.data(), clipboard_text, text_buffer_.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
if (input_submitted) {
|
||||||
text_ = std::string(text_buffer_.data(), text_buffer_.size());
|
text_ = std::string(text_buffer_.data(), text_buffer_.size());
|
||||||
cancelled_ = false;
|
cancelled_ = false;
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
|||||||
Reference in New Issue
Block a user